Presentation on theme: "Guidelines for Setting Field Properties Each field has a number of properties, such as its name and data type, that you can set when you define the field."— Presentation transcript:
Guidelines for Setting Field Properties Each field has a number of properties, such as its name and data type, that you can set when you define the field. Access has rules for naming fields, choosing data types, and defining other field properties. Well now look at guidelines for the following: Naming fields and objects Assigning field data types Assigning field sizes
Naming Fields and Objects You must name each field, table, and other object in an Access database. Its best to choose a name that describes the purpose or contents of the field or object, so that later you can easily remember what the name represents. For example, the two tables in our current database are named Client and Contract, because these names suggest their contents.
Naming Fields and ObjectsRules The following rules apply to naming fields and objects: A name can be up to 64 characters long. A name can contain letters, numbers, spaces, and special characters, except for a period (.), exclamation point (!), accent grave (`), and square brackets ([ ]). A name cannot start with a space. A table or query name must be unique within a database. A field name must be unique within a table, but it can be used again in another table.
Naming Fields and ObjectsTips In addition, experienced users of databases follow these tips for naming fields and objects: Capitalize the first letter of each word in the name. Avoid extremely long names because they are difficult to remember and reference. Use standard abbreviations, such as Amt for Amount and Qty for Quantity. Do not use spaces in field names because these names appear in column headings on datasheets and on labels on forms and reports. By not using spaces youll be able to show more fields at a time.
Assigning Field Data Types You must assign a data type for each field. The data type determines what field values you can enter for the field and what other properties the field will have. Access has these ten data types: AutoNumber, currency, date/time, hyperlink, lookup wizard, memo, number, OLE object, text, and yes/no. Descriptions of the most commonly used data types appear on the next page.
Most Commonly Used Field Data Types Data TypeDescriptionField Size TextAllows field values containing letters, digits, spaces, and special characters. Use for names, addresses, descriptions, and fields containing digits that are not used in calculations. 0 to 255 characters; 50 characters default NumberAllows positive and negative numbers as field values. Use for fields that you will use in calculations, except calculations involving money. 1 to 15 digits Date/TimeAllows field values containing dates and times from January 1, 100 to December 31, 9999. 8 bytes CurrencyAllows field values similar to those for the number data type. Unlike calculations with the number data type, calculations performed using the currency data type are not subject to round-off error. Accurate to 15 digits on the left side of the decimal point and to 4 digits on the right side
Assigning Field Sizes The field size property defines a field values maximum storage size for text, number, and AutoNumber fields only. The other data types have no field size property because their storage size is either a fixed, predetermined amount or is determined automatically by the field value itself. A text field has a default field size of 50 characters; you can also set its field size by entering a number in the range 1 to 255. When you use the number data type, you should set the fields field size property based on the largest value you expect to store in that field. Access processes smaller data sizes faster using less memory, so you can optimize your databases performance and its storage space by selecting the correct field size for each field.
Assigning Field SizesNumbers Field size property settings for number fields are: Byte: Stores whole numbers from 0 to 255 in one byte. Integer: Stores whole numbers from –32,768 to 32,767 in two bytes Long Integer (default): Stores whole numbers from –2,147,483,648 to 2,147,483,647 in four bytes Single: Stores positive and negative numbers to precisely seven decimal places and uses four bytes Double: Stores positive and negative numbers to precisely 15 decimal places and uses eight bytes Replication ID: Establishes a unique identifier for replication of tables, records, and other objects and uses 16 bytes Decimal: Stores positive and negative numbers to precisely 28 decimal places and uses 12 bytes