How to Call a Lookup Dialog

Previous Next

Lookup windows are called from query columns that are defined as a foreign key in a relationship.

By default they are called from Info Windows.

However, they may be called also from dialogs that have inserted text boxes: "lookup dialogs". This example shows how to create lookup functionality in a dialog.

If the user wants to use the lookup facility, she presses the lookup button and gets a default USoft lookup window on the Product table. She finds a possible Product value in this window and clicks some button to select it (OK, Apply ...). The selected value is copied into the calling dialog.

This construct offers maximum re-use of the default USoft lookup functionality, but at the same time offers all the flexibility of a manually painted dialog.

WI_clip0027

To call a lookup window from a field in a lookup dialog:

1.Use the Windows Designer to create and design the dialog class.
2.For the control where you want the lookup button, typically, a text box, set the Related Column property to:

<LOOKUP_TABLE>.<LOOKUP_COLUMN>

using capitals, e.g.:

PRODUCT.NAME

 

3.Select the Lookup Method property on the Behavior tab page, and click the Edit button to open the Object Activator for this property.
4.In the Object Browser pane, select the display control for the text box where you want the lookup button, for example:

Variables.Text_Box_1.Text_Box

The reason you need to do this is that the WindowCreateLookupDialog method is exposed by the column display control, not by the window as a whole.
5.In the Methods list, select the WindowCreateLookupDialog method, and click Add.
6.Select the subnode in the Script box, click Edit, and type the name of the lookup dialog class you want to call. This must be a subclass of the Lookup Dialog class.
The method call now looks like this:

Variables.Text_Box_1.TextBox.WindowCreateLookupDialog(<Lookup Window class name>)

7.Click OK to accept.

The lookup window does not support function keys such as F2 and F3, but it will take on the icon toolbar from the Lookup Dialog style sheet class.

For ease of design and maintenance, start by creating a special lookup dialog subclass.