Microsoft Access 2010 Bible

(Rick Simeone) #1

Chapter 6: Working with Datasheet View


225


Of course, you can define your own acceptable values in the Format property for the field, but
generally these values are the only acceptable ones. If you enter an invalid value, the warning
appears with the message to indicate an inappropriate value.

Tip
Display a check box in Yes/No fields to prevent users from entering invalid data.


Knowing how properties affect data entry
Because field types vary, you use different data-entry techniques for each type. In the “Saving the
record” section, earlier in this chapter, you learned that some data-type validation is automatic.
Designing tblContacts, however, means entering certain user-defined format and data-
validation rules. The following sections examine the types of data entry.

Standard text data entry
The first field — ContactID — in tblContacts is an AutoNumber field, while other fields in
the table are Text fields. After skipping ContactID, you simply enter a value in each field and
move on. The ZipCode field uses an input mask (00000\-9999;0;) for data entry. The Phone
and Fax fields also use an input mask (!\(999”) “000\-0000;0;). Text fields accept any
characters, unless you restrict them with an input mask.

Tip
To enter multiple lines in a Text or Memo field, press Ctrl+Enter to add a new line. This is useful, for example,
in large text strings for formatting a multiple-line address field.


Date/Time data entry
The OrigCustDate and LastSalesDate fields in tblContacts are Date/Time data types,
which both use a Short Date format (3/16/2012). However, you could’ve defined the format as
Medium Date (16-Mar-12) or Long Date (Friday, March 16, 2012). Using either of these formats
simply means that no matter how you type in the date — using month and year; day, month, and
year; or month, day, and year — the date always displays in the specified format (short date
[3/16/12], medium date [16-Mar-12], or long date [Friday, March 16, 2012]). Therefore, if you
type 4/8/13 or 8 Apr 13, Access displays the value in the specified format as you leave the field.
Dates are actually stored in the database without any formatting, so the format you select on a form
doesn’t affect how the data is stored.

Tip
Formats only affect the display of the data. They don’t change storage of data in the table.


Warning
In general, it isn’t a good idea to apply an input mask on Date/Time data. Microsoft Access does a more-than-
adequate job of validating date and time values. You’re far more likely to encounter data-entry problems with
an input mask on a date-containing control than you are to avoid trouble by using an input mask.

Free download pdf