|
When reviewing strings, we saw that the Field Size of a Text data type is used to specify the number of characters of the string. Numeric data types also use the
Field Size property. This time, this property is used to control the type or range of numeric values that would be accepted or excluded from the field. While the
Data Type column allows you to select the category of number, the Field Size field actually specifies the (Microsoft Visual Basic) data type that will (programmatically) be applied to the field.
A natural number is one that contains only one digit or a combination of digits and no other character, except those added to make it easier to read. Examples of natural numbers are 122, 8, and 2864347. When a natural number is too long, such
as 3253754343, to make it easier to read, the thousands are separated by a special character. This character depends on the language or group of languages and it is called the thousands separator. For US English, this character is the comma. The thousands separator symbol is mainly used only to make the number easier to read.
You should be careful to inherently use it in your database. Fortunately, your
users will be trained to deal with it.
To support different scenarios, Microsoft Acess provides different types of natural numbers:
Byte: A byte is a small but positive natural number that ranges from 0 to 255. This type of number is applied to such items
as a person's age, the number of students in an elementary classroom, the number of rooms in a regular house,
the number of pages of a magazine or newspaper, etc. If you are creating a field that will need this range of values, after setting its
Data Type to Number set its Field Size to Byte.
Integer: An integer is a natural number larger than the Byte. It can hold a value between
-32,768 and 32,767. Examples of such ranges are: the number of pages of a book. For a field that would hold this range of values, set its
Field Size to Integer.
Long Integer: A long integer is a natural number whose value is between
–2,147,483,648 and 2,147,483,642. Examples are the population of a city, the distance between places of different countries,
Number of words of a book. For such a field, set its Data Type to
Number and its Field Size to Long Integer.
In our examples, we were giving types of fields for each kind. It is important to note that, since a long integer can
hold larger numbers than the integer, anything applied as an integer can also be used as a long integer. For example, you can use a long integer to represent the number of pages of a book, even if the books in a collection are not expected to hold more than 1500 pages. In the same way, since an integer is larger than a byte, anything that fits in a byte can also be used as an integer. Based on this, an integer can be used to represent the categories items in a collection, even if the items are not expected to be higher than 200. For example, you can use an integer to count the number of keys on a computer keyboard, knowing that this number is expected to stay below 148.
|
Practical Learning: Using Natural Numbers on Fields
|
|
- Open the Clarksville Ice Scream database and, from the Tables section, click the New button
- In the New Table dialog box, click Design View and click OK
- Set the first Field Name to ScoopsID and make it a press the down arrow key
- Set the second Field Name to Scoops and press Tab
- Set its Data Type to Number and press F6
- In the Field Size combo box, select Byte
If you create a field that will be used to keep an index of records as they are entered and/or deleted, you can set its Data Type to AutoNumber. This would ask Microsoft Access to complete that field with automatically generated numbers for a field whose number you do not need to control. This technique is highly used for the first field of a table.
|
Practical Learning: Using an Automatic Number
|
|
- The Clarksville Ice Scream database should still be opened with the Table1 in Design View
In the upper section of the table, click ScoopsID and press Tab
- Change the ScoopsID Data Type to AutoNumber
- Close the table to save it. Give it the name Scoops and press Enter
- When asked whether you want to create a Primary Key, click No
- Open the Employees table in Design View
- In the upper section of the table, click EmployeeID and press Tab
- Click the arrow under the Data Type and click AutoNumber
- Save the table
|

A real number is a number that displays a decimal part. This means that the number can be made of two sections separated by a symbol that is referred to as the Decimal Separator or Decimal Symbol. This symbol is different by language, country, group of languages, or group of countries. In US English, this symbol is the period as can be verified from the Regional (and Language) Settings of the Control Panel of computers of most regular users:

On both sides of the Decimal Symbol, digits are used to specify the value of the number. The number of digits on the right side of the symbol determines how much precision the number offers.
Microsoft Access provides two types of decimal numbers:
Single: A single is a decimal number whose value can range from –3.402823e38 and –1.401298e-45 if the number is negative, or
1.401298e-45 and 3.402823e38 if the number is positive. To use this type of numbers on a field, set its
Field Size to Single.
Double: While the Single data type can allow large numbers, it offers less precision. For an even larger number, Microsoft Access provides the Double data type. This is used for numbers that range from
1.79769313486231e308 to –4.94065645841247e–324 if the number is negative or from
1.79769313486231E308 to 4.94065645841247E–324 if the number is positive.
Similar to the relationships among natural numbers, a Single can fit a Double. In fact, you may see that, with experience and if you check the databases (and VBA code) of most programmers, they use the
Double most of the time. Although the Double type uses more memory, it offers higher precision than the
Single, which sets its preference.
The Currency data type is used for a field made for monetary values. For such a field, set its
Data Type to Currency. During data entry, the user can type a decimal number and press Enter, Tab or click somewhere else. The number would then be converted to represent money value. The number would also display the currency symbol on its left. Like the Decimal Symbol, the character used for currency depends on the country or a group of countries. It can also be verified in the Regional (and Language) Settings of Control Panel.
The Currency data type does not have a Field Size property on
database objects. Instead, it uses the Format property to specify how the number would be displayed:

|
Practical Learning: Using the Currency Data Type
|
|
- The Clarksville Ice Scream database should still be opened
with the Employees table is Design View
In the upper section of the table, click Salary and press Tab. Click the arrow of the combo box and select
Currency
- Save the table
A data field is referred to as Boolean when it can assume only one of two values. It can be either Yes or No, True or False, On or Off, non-zero or 0. Such a field is appropriate when you want the user to indicate the state of a value.
To specify that a field is Boolean, set its Data Type to
Yes/No.
To support various ways of expressing a Boolean field, Microsoft Access provides various options. After setting the
Data Type of a field to Yes/No, you can control how the field would be presented to the user. The most classic way consists of displaying a check box:

With this layout, the user can either click the check box or give it focus and press the space bar. Alternatively, if you prefer, you can let the user type a value. In
this case, after setting the field’s data type to Yes/No, in the lower section of the table in Design View, click the Lookup property page and, on the Display Control combo box, select one of the available items:

The default option is Check Box. If you select Text Box, then the user will be able to type
True, False, Yes, No, On, Off, 0, or any number. Once the user types one of these values and press Enter, Tab, or clicks somewhere else, you can control how the field would display the value. To do this, in the lower section of the table in Design View, click the General property page and, in the Format property, select one of the available options:

If you set the Format property to Yes/No and if the user types 0, the field would display
No; if the user types any other number, the field would display Yes.
If you set this property to True/False and if the user types 0, the field would display False; if the user types any other number, positive or negative (but it must be a number) the field would display True:

|
Practical Learning: Using Boolean Field
|
|
- The Clarksville Ice Scream database should still be opened with the Employees table in Design View
In the upper section of the table, click MaritalStatus and press Tab
- Set its Data Type to Yes/No
- In the lower section of the table, click the Lookup property page. From the Display Control combo box, select Text Box
- Click the General tab and, in the Format property, make sure that Yes/No is selected
- Save the table
|
Document and Object Linking |
|
Object Linking and Embedding (OLE) is a technique that consists of adding in your database (not just database, but our discussion will stop to Microsoft Access databases as if OLE had to do only with Microsoft Access) an object that was created using another application. The technique used to include such an object is particularly easy.
Over all, Microsoft Access does not care much what type of object you want to add to, or include in, your database. It is left to you to decide why you want to include the object and what type of object this would be. Some objects (can tremendously) increase the size of your database.
To use an OLE object in a field, create the data field in the Design View of a table and set its Data Type to OLE Object.
After setting the Data Type of a field as OLE Object, since the object is external, there are not too many options or properties provided by the table. The application in which you created or will create the object should control it. To actually include an external object into the field, whether using the table Datasheet View or the form in Form View, the user can right-click the field and click Insert Object. This would open the Insert Object dialog box that presents two options to create or select the object:

- If you want to use an application installed in your application to create the document, you can click the Create New radio button. Then, in the Object Type list, click the application and click OK
- If the object has been created and resides on a portable media (floppy disk, CD, DVD, etc), on your hard drive or on the network your computer is connected to, you can click the Create From File radio button and click Browse. This would bring the Browse dialog box that allows you to locate and select the document
|
|