Implementing lookups

Two methods are used to implement lookups. The first method involves specifying the lookup form for a global or local field definition. The second method involves creating a lookup push button and setting up a lookup link in the layout window.

Specifying a lookup form

The Field Definition window and the Local Field Definition window each have a Lookup Form field. This field specifies the lookup form to open when the focus is on that field and the Lookup menu item is chosen. A return path for the lookup is automatically set up when the Lookup menu item is chosen. The return statement returns a value from the lookup window to the field. For example, the Customer ID global field has the Customer_Lookup form designated as the lookup form.

When the focus is in the Customer ID field and the Lookup menu item is chosen, the Customer_Lookup form will open. A return path will be set up back to the Customer ID field. The Customer_Lookup form will return the selected value to the Customer ID field.

[spacer]

If a lookup form has been designated for a field, the lookup window will work for any occurrence of the field in the application. For instance, in the previous example, the lookup would work anywhere you used the Customer ID field in the application. If you don’t want a specific instance of the field to access the lookup form, set the DisableLookup property for that instance of the field to true.

Using a lookup button

The second and more common method of implementing a lookup is to add a push button to the window. This push button opens the lookup form and sets up the return path from the lookup window. The Buyer ID field and its lookup button are shown in the following illustration.

[spacer]

The lookup button for the Buyer ID field opens the Buyer_Lookup form and sets up the return path back to the Buyer ID field. The lookup form uses the return statement to return a value to the lookup field. The following script is attached to the lookup button.

open form Buyer_Lookup return to 'Buyer ID';

One way to open the lookup is to click the lookup button. Dexterity also has the capability to make the Lookup menu item open the lookup form by effectively “clicking” the lookup button. To do this, open the layout window containing the field and lookup button. Choose Link Lookup from the Tools menu; Dexterity will enter lookup linking mode. Simply click on the field and drag to the lookup button. A flashing black line indicates the link was made.

[spacer]

Choose Link Lookup from the Tools menu to exit lookup linking mode.

In the preceding example, whenever the focus is in the Buyer ID field, the Lookup menu item will be enabled. Choosing the Lookup menu item will run the change script for the lookup button, which in turn opens the lookup form and sets up the return path.

You should also set the Hyperspace property for the lookup button to True. This will prevent the change script or post script for the editable field from running. The change script or post script could potentially keep the lookup button script from running.

A field linked to a lookup button is the most common implementation of a lookup. This is because additional processing can be done by the lookup button script, in addition to opening the lookup form and setting up the return path.


 


Documentation Feedback