Presentation is loading. Please wait.

Presentation is loading. Please wait.

MS ACCESS.

Similar presentations


Presentation on theme: "MS ACCESS."— Presentation transcript:

1 MS ACCESS

2

3 Create a new table using a table template, Access includes template for common subjects suchas contacts, issues , and tasks To create a Contacts, Tasks, Issues, Events or Assets table, you might want to start with the table templates for these subjects that come with Office Access The table templates were designed to be compatible with the Microsoft Windows SharePoint Services 3.0 lists of the same name

4 Create a table based on a SharePoint list
You can create a table in your database that imports from or links to a SharePoint list. The list can pre-existing, in which case you can import or link to it, or you can create a new custom list or a new list that is based on a predefined template. The predefined templates in Office Access 2007 include Contacts, Tasks, Issues and Events.

5 Add fields to a table in Datasheet view

6 Add New Field Insert a new filed (column) into the table, so that you can store a specific type of information Add Existing Fields insert a filed into this view, based on an existing field

7

8 Add a templated datasheet to an existing database

9 Dr. Anup Kumar

10 Set the Attachment or OLE Object data types
When you use Datasheet view to create a new table, you can set most data types by entering some data in the first row of a field. However, you cannot use that method to set the Attachment and OLE Object data types; you must set those data types manually by using the Set Data Type list on the Datasheet tab, or by using the table designer. The steps in this section explain how to use both methods to set the data types. Datasheet tab, in the Data Type & Formatting group, click the down arrow next to Data Type Dr. Anup Kumar

11 Manage the fields in a datasheet
Right-click a column header and select a command from the shortcut menu.

12 Table using Design View
Dr. Anup Kumar

13 Difference between Datasheet View & Design View
Datasheet view shows the data in the database. It also allows you to enter and edit the data. Design view shows the field and their data types along with other properties, but not the data and we can also make changes to the design of the table. WHEREAS  The datasheet view shows the actual data and we can also change the data in it, but not the design of the table.

14 Difference between Datasheet View & Design View
It does not let you change the format of the database only minor changes can be made to the actual database format. One such change that can be made to the format is adjusting the column width of a table 2. Fields can also be configured to set appropriate keys and restrictions on type of data entered in them

15 b)     Design view provides more control over the table structure
WHEREAS Datasheet view doesn’t provide any control over the table structure.

16 Field Property Every table in Access is made up of fields.
The properties of a field describe the characteristics and behavior of data added to that field. A field's data type is the most important property because it determines what kind of data the field can store.

17 Data types can seem confusing for example, if a field's data type is Text, it can store data that consists of either text or numerical characters. But a field whose data type is Number can store only numerical data. So, you have to know what properties are used with each data type. A field's data type determines many other important field qualities, such as the following: Which formats can be used with the field. The maximum size of a field value. How the field can be used in expressions. Whether the field can be indexed. A field's data type can be predefined or you will select a data type depending on how you create the new field. For example, if you create a field from the Datasheet view and:

18

19

20 Field properties A field's data type does not only determine the type of data you can put in. It also determines theproperties you can set on the field as you will see in the next sections.  The Text data type The Text data type is used very often for names, descriptions, titles, et cetera. Text fields can contain a maximum of 255 characters of tex

21 The maximum number of characters you can enter
The maximum number of characters you can enter. The largest maximum you can set is 255.

22

23

24

25 Property Explanation Field Size
The most important properties of the Text are below. Property Explanation Field Size The maximum number of characters you can enter. The largest maximum you can set is 255. Format Rules for the display of this field in the datasheet Input mask In input mask is a pattern that all data entered in this field must adhere to Caption When a caption text is entered, it is displayed as a field label in forms. If nothing is filled out, the filed name is used for this purpose. Default value The default value is inserted by Access automatically when no other value is supplied for the field. Validation rule A rule that validates the input. Read more on validation rules in the validation rules tutorial. Required Indicated whether a value is required for this field. Access will show an error message and won't insert the new record if you try to insert a new record that has no value for a required field. Allow Zero Length Indicates whether you are allowed to insert a text that contains zero characters.  Indexed Apply an index when you want to allow for fast searching on the field's contents or when you want to impose a unique constraint (Select "Yes, no duplicates") on the field.

26 The Number data type The Number data type in Access is a data type for different types of numbers, like Integer, Long Integer, Byte, Decimal, et cetera. The exact number type is configured using the Field Size property. When creating a new Number field the Field Size property defaults to Long Integer. So by default, the Number field can contain whole numbers.

27

28 InputMask You can use the InputMask property to make data entry easier and to control the values users can enter in a text box control. An input mask is a set of simple rules that specifies the format in which data can be entered into a field Add two zeros, so that the input mask becomes: 99->L<LL-0000 This will ensure the user enters the date as DD-MMM-YYYY. For example, 20-Mar-2016.

29

30

31 Our Input Mask Explained
The 99 part defines two optional numbers (i.e. for the day). So the user has a choice of entering that part of the date. But if they do, it must be a number. The >L specifies that the user must enter an uppercase letter for that part of the date. The <LL specifies two lowercase letters for that part of the date. The 0000 specifies four numbers for that part of the date.

32 Characters that define input masks
User must enter a digit 9 User can enter a digit # User can enter a digit, space, plus or minus sign. If skipped, Access enters a blank space. L User must enter a letter ? User can enter a letter A User must enter a letter or digit a User can enter a letter or digit

33 The Date/Time data type

34 The Currency data type The Currency data type also adapts to the region and language settings of the operating system. But you can override this behaviour.

35 The Yes/No datatype The Yes/No datatype is called a boolean data type in most databases. The Yes/No data type is pretty simple. It just lets you chose between Yes and No :). This data type is used for yes/no questions. Does this user want to receive our weekly newsletter? Yes or no? Have we received payment for this order? Yes or No?

36 The Hyperlink datatype
The Hyperlink datatype is a text field, but a bit fancier. It won't surprise you that this field is used to store links. In the data sheet, the stuff you type into a Hyperlink field is automatically prepended with by Access and it is displayed as a clickable link. The Attachment datatype The Attachment datatype is used to store one or more files in a database field. If you set a field to the Attachment data type a small paperclip will display in the Access data sheet. 

37 The calculated data type
The calculated data type lets you store the result of a calculation that includes data from other fields, like the amount of product x the product price. In database design it is considered bad practice to store information that can be derived from other fields, because you would be storing the same information in two locations and you would be forced to manage that information in two places. 

38

39 Validation Rule

40 Database View Pivot Table View Pivot chart View Design View

41 About restricting or validating data
provides a variety of ways to control how users enter data into your database. 1. Using data types and field properties to restrict or validate data in tables Text Date Number Data and Time etc. 2. Validation rules For example, you can limit the data that a user can enter into a field by defining a validation rule for that field. If the data that a user enters into the field breaks the rule, Access will display a message telling the user what kind of entries are allowed. Another method of controlling data entry is to create an input mask to restrict the kind of values that can be entered in positions across the field. You can perform these simple forms of validation and restriction by setting properties for fields in tables, or by setting properties for controls on forms.

42 Validation Rules Validation rule  display a message telling the user what kind of entries are allowed. valid input values for a field or record in a table, check the value entered into a field as the user leaves the field. rule to limit what will be accepted prevent bad data being saved in your table ValidationText displays the message specified in the ValidationText property when t he rule is violated.)

43 You can use the ValidationRule property to specify requirements for data entered into a record, field, or control. When data is entered that violates the ValidationRule setting, you can use the ValidationText property to specify the message to be displayed to the user. Read/write String Microsoft Access automatically validates values based on a field's data type; for example, Microsoft Access doesn't allow text in a numeric field. You can set rules that are more specific by using the ValidationRule property. If you set the ValidationRule property but not the ValidationText property, Microsoft Access displays a standard error message when the validation rule is violated. If you set the ValidationText property, the text you enter is displayed as the error message.

44 Accept letters (a - z) only Is Null OR Not Like "[!a-z]"
To do this ... Validation Rule for Fields Explanation Accept letters (a - z) only Is Null OR Not Like "[!a-z]" Any character outside the range A to Z is rejected. Accept digits (0 - 9) only Is Null OR Not Like "[!0-9]" Any character outside the range 0 to 9 is rejected. (Decimal point and negative sign rejected.) Digits and letters only Is Null OR Not Like "[!((a-z) or (0-9))]" Accepts A to Z and 0 to 9, but no punctuation or other characters. Exactly 8 characters Is Null OR Like "????????" The question mark stands for one character. Exactly 4 digits Is Null OR Between 1000 And 9999 For Number fields. Is Null OR Like "####" For Text fields. Positive numbers only Is Null OR >= 0 Remove the "=" if zero is not allowed either. No more than 100% Is Null OR Between -1 And 1 100% is 1. Use 0 instead of -1 if negative percentages are not allowed.

45 Not a future date Is Null OR <= Date() address Is Null OR ((Like AND   (Not Like "*[ ,;]*")) Requires at least one at least one character, dot, at least one character. Space, comma, and semicolon are not permitted. You must fill in Field1 Not Null Same as setting the field's Required property, but lets you create a custom message (in the Validation Text property.) Limit to specific choices Is Null OR "M" Or "F" It is better to use a lookup table for the list, but this may be useful for simple choices such as Male/Female. Is Null OR IN (1, 2, 4, 8) The IN operator may be simpler than several ORs.

46 Yes/No/Null field Is Null OR 0 or -1 The Yes/No field in Access does not support Null as other databases do. To simulate a real Yes/No/Null data type, use a Number field (size Integer) with this rule. (Access uses 0 for False, and -1 for True.) To do this ... Validation Rule for Table Explanation A booking cannot end before it starts ([StartDate] Is Null) OR ([EndDate] Is Null) OR ([StartDate] <= [EndDate]) The rule is satisfied if either field is left blank; otherwise StartDate must be before (or the same as) EndDate. If you fill in Field1, Field2 is required also ([Field1] Is Null) OR ([Field2] Is Not Null) The rule is satisfied if Field1 is blank; otherwise it is satisfied only if Field2 is filled in. You must enter Field1 or Field2, but not both ([Field1] Is Null) XOR ([Field2] Is Null) XOR is the exclusive OR.

47 A Validation rule of >= #01/01/2000# and <Date() (meaning after Jan and before Today <>0 Enter a zero value (Zero is not accepted) msg shown I u enter 0 0 Or >100 Value must be either 0 or over 100 Like "P???" Value must be four characters beginning with the letter P. <#1/1/99# Enter a date before 1999 >=#1/1/98# And <#1/1/99# The date must be in 1998 >=Date() Date can't be before today's date >=Date()+365 Date must be at least one year from today

48

49 Input mask where data is to be entered as well as what kind of data and how many characters are allowed.) Use an input mask to simplify data entry in Access It's much easier to enter phone numbers if you don't have to type the hyphens and parentheses

50 Character Description Digit (0 through 9, entry required; plus [+] and minus [-] signs not allowed). 9 Digit or space (entry not required; plus and minus signs not allowed). # Digit or space (entry not required; blank positions converted to spaces, plus and minus signs allowed). L Letter (A through Z, entry required). ? Letter (A through Z, entry optional). A Letter or digit (entry required). a Letter or digit (entry optional). & Any character or a space (entry required). C Any character or a space (entry optional). . , : ; - / Decimal placeholder and thousands, date, and time separators. (The actual character used depends on the regional settings specified in Microsoft Windows Control Panel.) < Causes all characters that follow to be converted to lowercase. > Causes all characters that follow to be converted to uppercase.

51 ! Causes the input mask to display from right to left, rather than from left to right. Characters typed into the mask always fill it from left to right. You can include the exclamation point anywhere in the input mask. \ Causes the character that follows to be displayed as a literal character. Used to display any of the characters listed in this table as literal characters (for example, \A is displayed as just A). Password Setting the InputMask property to the word Password creates a password entry text box. Any character typed in the text box is stored as the character but is displayed as an asterisk (*).

52 Create a Lookup Column If a field can contain a finite list of values, you can create a Lookup Column and users can select the value they want from a list. For example, if the employees at a school can only work in one of the following departments: Administration, Computer Science, English, History, or Math. You can create a table Departments table that lists the departments and then use the list in the Employee table to assign each employee to a departme

53

54 Guide to table relationships
One of the goals of good database design is to remove data redundancy (duplicate data). To achieve that goal, you divide your data into many subject-based tables so that each fact is represented only once

55

56 Types of table relationships
A one-to-many relationship Consider an order tracking database that includes a Customers table and an Orders table. A customer can place any number of orders. It follows that for any customer represented in the Customers table, there can be many orders represented in the Orders table. The relationship between the Customers table and the Orders table is, therefore, a one-to-many relationship. To represent a one-to-many relationship in your database design, take the primary key on the "one" side of the relationship and add it as an additional field or fields to the table on the "many" side of the relationship. In this case, for example, you add a new field — the ID field from the Customers table — to the Orders table and name it Customer ID. Access can then use the Customer ID number in the Orders table to locate the correct customer for each order.

57 A many-to-many relationship Consider the relationship between a Products table and an Orders table. A single order can include more than one product. On the other hand, a single product can appear on many orders. Therefore, for each record in the Orders table, there can be many records in the Products table. In addition, for each record in the Products table, there can be many records in the Orders table. This type of relationship is called a many-to-many relationship because, for any product, there can be many orders and, for any order, there can be many products. Note that to detect existing many-to-many relationships between your tables, it is important that you consider both sides of the relationship. To represent a many-to-many relationship, you must create a third table, often called a junction table, that breaks down the many-to-many relationship into two one-to-many relationships. You insert the primary key from each of the two tables into the third table. As a result, the third table records each occurrence, or instance, of the relationship. For example, the Orders table and the Products table have a many-to-many relationship that is defined by creating two one-to-many relationships to the Order Details table. One order can have many products, and each product can appear on many orders.

58 Understanding referential integrity

59

60 Open the table to which you want to add a lookup column.
Click the field label for the field before which you want to add a lookup column. Activate the Datasheet tab. (You must be in Datasheet view.) Click the Lookup Column button in the Fields & Columns group. The Lookup Wizard appears. Make sure the radio button next to “I want the lookup column to look up the values in a table or query.” is selected. Click Next. The Lookup Wizard moves to the next page. Select your table or query A lookup column can be based on a table, a query, or a list of values you type. If you base your lookup column on a table or query, you must create the table or query before creating the lookup column. A query is a list of rows and columns based on one or more tables. A query only displays the rows and columns you specify.

61

62 Click a radio button to select what you want to base your lookup column on. Choose from Tables, Queries, or Both. Click to select the table or query you want. Click Next. The Lookup Wizard moves to the next page.

63 Select fields You choose the fields you want to appear in your lookup column. Be sure to include the primary key

64 Click the field you want.
Click the single right-arrow button . Access places the field in the Selected Fields column. Repeat this process to select additional fields. If you want all the fields in the table, click the double right-arrow button . Note: Use the single left-arrow  and the double left-arrows  to deselect fields. Click Next. The Lookup Wizard moves to the next page.

65

66

67

68


Download ppt "MS ACCESS."

Similar presentations


Ads by Google