Using Field Rules to Generate A Table Lookup

Description

The Product List tab contains an embedded browse named Browse1 that displays data from the Product table. When the user clicks on the Vendor ID column (the Vendor field of the Product table), a popup displays a lookup list of records from the Vendor table. Selecting and entry in this list and clicking the OK button returns the vendor_id from the Vendor table and saves it in the Vendor field of the Product table. The popup list is generated by the field rules associated with the Vendor field of the Product table.

Procedure: Setting Field Rules to Generate a Lookup List 

The following procedure assumes that the developer has opened the form in the Form Editor. Follow these instructions to create a popup lookup list similar to that of Browse1 on the Product List tab of the Inventory form:

  1. In the Control Panel click the Tables/Sets tab.

  2. Right click the Product table icon and select Edit Field Rules... .

  3. Click the Lookups tab.

  4. Select "PRODUCT->VENDOR" from the field list.

  5. In the Lookup styles field select "Table lookup".

  6. Select the Vendor table in the Table list.

  7. Select "VENDOR_ID" in the Linking Field list. This the field in the Vendor table whose value will be returned and stored in the Product->Vendor field.

  8. Select name in the Display Order field. This sorts the Vendor->name entries alphabetically.

  9. Skip the Filter field. An expression in this field would limit the Vendor->name entries that are shown if there was a reason not to show all of them.

    images/AL_form_inventory_product_field_rules0.gif
  10. Select the first column of data to appear in the popup list.

  11. Select "VENDOR->Vendor_ID" in the first line of the Source column.

  12. In the first line of the Fill column enter "Vendor". This is the Product table field that will receive the value of vendor_id.

  13. Select "Yes" in the first line of the Display column.

  14. Select the second column of data to appear in the popup list.

  15. Select "VENDOR->Name" in the second line of the Source column.

  16. Skip the second line of the Fill column. This data is for the user's information only. It will not be saved into the Product table.

  17. Select "Yes" in the second line of the Display column. Picture

    images/AL_form_inventory_product_field_rules1.gif
  18. Skip Display as Drop-down list box . This option presents the table list in a combo box format.

  19. Skip User can add records to lookup table . This option adds the Enter button to the popup.

  20. Skip User edit add records in lookup table . This option adds the Change button to the popup.

  21. Skip Unique records only . The table design presumes that there are no duplicate records.

  22. The Form layout to edit records field defines the form to use if the Change or Enter buttons are enabled above. If nothing is defined, Alpha Anywhere uses the Default Form

  23. The Browse layout to display field selects the browse to use when the user click the Browse button. If nothing is defined, Alpha Anywhere uses the Default Browse .

  24. Select "Popup on mismatch" in the Allow exceptions list. This defines the way to handle values that do not match the field's requirements.

  25. Select "Popup conditionally on entrance" in the Auto popup list. This says to automatically display the popup window when entering a new record or when the Popup condition is met.

  26. Enter isblank("Vendor"). The Popup condition could be any expression. In this case the pop-up window appears if the field is blank.

  27. The Position field specifies where to place the pop-up window. "Top left" is the default.

  28. Check the Allow maximized display check box if you want to allow the pop-up window to be maximize when the underlying form is maximized.

    images/AL_form_inventory_product_field_rules2.gif

See Also