Define a dynamically populated ComboBox
Populated Combobox Example
In this example, when the user is in an input mode and selects the ComboBox field, a list of
the valid country descriptions are displayed. When the user selects a country description
(country.codedesc
) and accepts the selection, the account
table is
updated with the correct country information (account.country
).
- Modify the form. Find the master field that is to be replaced with a ComboBox of populated
values and move it to another location on the form. You can convert this field to a Phantom widget
as it will be needed for the code, but not needed to display to the user
(
account.country
in this example). - On the Records tab, add the reference field to the master field in the same record.
Right-click on the record and choose Add Field. (The
country.codedesc
field, the field representing the list of country descriptions, is added to the account record in this example.) - Right-click on the record and select Edit Query. Establish the join between the master
table and reference table. (
account.country
is joined tocountry.code
in this example.) - Select the reference field in the record and set its
lookup
property. This name will be used as a function name in the generated code that is triggered to perform the ascending lookup. - Return to the Form tab. Notice that the new field
(
country.codedesc
) has been added to the form in the upper left. Move it to its correct location and convert it to a ComboBox widget. - Set the
initializer
property on the ComboBox field to a unique name. This name will be used as a function name for the generated code that populates the ComboBox when it is built in the user interface. - Save the form. Build and Execute the program.