|
Chapter 6: Keeping Your Information Accurate continued
Using a Lookup List to Restrict DataIt is interesting how many different ways people can come up with to enter the same items of information in a database. Asked to enter the name of their home state, for example, residents of the state of Washington will type Washington, Wash, or WA, plus various typos and misspellings. If you ask a dozen sales clerks to enter the name of a specific product, customer, and shipper in an invoice, the probability that all of them will type the same thing is not very high. In cases like this, where the number of correct choices is limited (to actual product name, actual customer, and actual shipper), providing the option to choose the correct answer from a list will improve your database’s consistency.Minor inconsistencies in the way data is entered might not be really important to someone who later reads the information and makes decisions. Most people know that Arizona and AZ refer to the same state. But a computer is very literal, and if you tell it to create a list so that you can send catalogs to everyone living in AZ, the computer won’t include anyone whose state is listed in the database as Arizona. You can limit the options for entering information in a database in several ways:
In this exercise, you will use the Lookup Wizard to create a list of months from which the user can choose. You might use something like this to gather credit card information. The working folder for this exercise is SBS\Access\Accurate\Lookup. Follow these steps:
The first page of the Lookup Wizard is displayed: You can use this wizard to create a combo box that provides the entry for a text field. The combo box list can come from a table or query, or you can type the list in the wizard.
TIP: If a field has a lot of potential entries, or if they will change often, you can link them to a table. (You might have to create a table expressly for this purpose.) If the field has only a few items and they won’t change, typing the list in the wizard is easier.
A combo box typically has only one column, but it can have more. On this page, you can set the number of columns and then enter the text that should appear in each one. If you specify more than one column, you also have to specify which column’s text should be entered in the field when a selection is made from the list.
The wizard entered this information, but you could easily figure out what you would have to enter to create a lookup list by hand.
As soon as you type the J, the combo box displays January. If you had typed Ju, the combo box would have jumped to June.
The entry is accepted just as you typed it. Although there might be times when you want to allow the entry of information other than the items on the list, this isn’t one of those times.
The last property on the Lookup tab is Limit To List. It is currently set to No, which allows people to enter information that isn’t on the list.
Access informs you that the text you entered is not on the list, and refuses the entry.
A list of the names of months is convenient for people, but if your computer has to deal with this information in some mathematical way, a list of the numbers associated with each month is easier for it to use. There is a solution that will work for both humans and machines.
The wizard now looks as shown on the next page.
You return to the table, with the Field Properties section displaying the Lookup information, like this: The wizard has inserted your column information into the Row Source box and set the other properties according to your specifications.
Access displays the number 1 in the field, which is useful for the computer. However, people might be confused by the two columns and by seeing something other than what they clicked or typed.
Only the name of the month is now displayed in the list, and when you click a month, that name is displayed in the field. However, Access actually stores the associated number from the list’s first column.
Only the two records with February in the Month2 field are now displayed.
Last Updated: Saturday, July 7, 2001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||