Add a Lookup Field
Objectives:
- Understand lookup fields
- Add a lookup field to your view and the underlying table
- Update records in your table to add data from the lookup field
Estimated time to complete: 10 minutes
Skill level: Beginner
You may find that some data in your application needs to be entered again and again. For example, the Fremont Book Club meets at one of three places: the pub, the coffee shop, or the downtown library. Rather than typing this data in for each meeting, and running the risk of mispelling it, you can create a lookup field. The lookup field provides you with a drop-down list of possible values to choose from.
* To add a lookup field to your table, follow these steps:
- Edit the default.view file in the Books folder in the Designer, if you're not already.
- Select the view's data region.
- Choose Insert > New Field, then click the Custom Fields tab. Enter the following data to create a new field:
- Field Name: Location.
- Data Type: Text.
- Caption: Location.
- Click the Options button.
- Enter these names on separate lines in the Options dialog:
- Pub
- Coffee Shop
- Downtown Library
- Click Ok to close the Options dialog.
- Click Finish.
If you look at the File Directory, you may notice that a new folder has been added to your application, the Lookups folder. Within this folder is a data table named Location, containing the data you entered above. A lookup field actually looks up data that is stored in another table in your application. To add a new location, you would insert a new record in the Location table.
Assign locations Next we need to assign a location for each meeting that exists on the schedule.
* Follow these steps to modify the data in the Books table:
- Click on the Preview tab to browse the view within the Designer. Your view should appear in grid mode.
- Click on the Details link for a record to display it in details mode.
- Click the Edit button to display the record in update mode.
- Select a location for the record and click the Submit button.
- Repeat for each row.
|