Define a dynamically populated combobox


This figure shows an example of a Combobox with populated values.

Figure 1. Combobox with Data

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).

  1. 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).

  2. 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.)

  3. Right-click on the record and select Edit Query. Establish the join between the master table and reference table. (account.country is joined to country.code in this example.)

  4. 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.
    This figure shows the lookup property for the Combobox set to lookupCountry.

    Figure 2. Lookup

  5. 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.

  6. 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.
    This figure shows the Combobox initializer property set.

    Figure 3. Combobox Properties

  7. Save the form. Build and Execute the program.