Lookup Fields

In the TDBGrid, your application shows the key of the priority record that indicates the priority of the task. It would be better to see the name of the priority instead of its ID. Just as with local data, you can set this up in Data Abstract using a lookup field.

When you created the project, in addition to selecting the Tasks table from the schema, you also selected the Priorities table and you should already have the tbl_Priorities and ds_Priorities components in the DataModule.

Setting up a Lookup Field

In the DataModule, select Add LookUp Field from the tbl_Tasks components context menu.

Data Module - Add Lookup Field

Set the ds_Priorities component as the lookup source in the Lookup field editor. Select the ID field as the field to look up using the Priority field as the key. Give the lookup field the name PriorityName. Click Add Button to create the lookup field.

Change the Priority column in the DBGrid on the client form to now use the PriorityName field.

Data Module - Add Lookup Field

Testing the Lookup Field

When you run your application now, instead of seeing the value of the property field from the task record in the Priority column, you should see the appropriate name value from the corresponding record in the Properties table.

Client Application - Lookup Field