Creating Conditional Table Lookups
When one of several tables might supply the field's value, use a Conditional table lookup. Instead of choosing one lookup table, you complete the Table Conditions table, filling in the names of two or more tables along with a Conditional expression for each that determines which table is used for the lookup. The tables you use must have the same field names and types since there is only one field mapping.
Defining a Conditional table lookup involves:
Completing the Conditional Tables table
Specifying a linking field
Specifying the display order of lookup table records (optional)
Mapping the fields
If you selected "Conditional Table Lookup", select the first table that is providing the information in the Table column. Click the 'open folder' icon to navigate to and select the table. Typically, the lookup table has a field in common with the fill (destination) table.
In the Condition column, enter a condition that defines when to use this particular table for the value lookup. Click the 'x-y' icon to use the Expression Builder to help construct an expression. When you specify the expression that determines in which table Alpha Anywhere will perform the lookup, you might find the Alpha Anywhere system variable, a_field_value to be useful. This variable contains the value in the current field. For example, the following shows how a conditional table lookup could be defined. If the part number that was entered into the lookup field is found in the wholesale_price.dbf table, then that table is used as the lookup table. Otherwise, the retail_price.dbf table is used.
Repeat steps 1 and 2 for each additional table that you want to use conditionally.
The Linking Field for a Conditional table lookup has the same purpose as the linking field for a table lookup. When defining a Conditional table lookup, you select the linking field from the first lookup table you listed in the Conditional Tables table. This linking field must exist in all lookup tables.
Optionally, enter a field name or character order expression in the Display Order field that will order the list that you retrieve from the lookup table. Click the 'x-y' icon to use the Expression Builder to help construct an expression.
Optionally, in the Filter field enter a character filter expression that will select records for the list that you retrieve from the lookup table. Click the 'x-y' icon to use the Expression Builder to help construct an expression.
In the Source column of the next embedded browse, click the 'down' icon to select the fields from the lookup (source) table that you want to use. Place each field in a separate row. Since the structure of all the Conditional lookup tables must have fields in common, you complete the Field Mapping table just once, selecting the source fields from the first lookup table you listed. All the other conditional tables will be mapped in the same way.
In the Fill column, to the right of each Source entry, click the 'down' icon to select the fields from the current (fill) table that you want to fill.
In the Display column, to the right of each Fill entry, select "Yes" or "No" to indicate whether this field will be visible in the user's selection list.
Optionally, in the Width column specify the width (in characters) that each displayed field will have in the user's selection list. If you do not enter a setting, the entire field is displayed.
Optionally, use the Condition column in the embedded browse to specify that a record may not be included in the selection list. It will only appear if the character filter expression you write evaluates to TRUE (.T.). Refer to Displaying Selected Lookup Table Records (Filtered Lookups).
Optionally, check User can add records if you would like the user to be able to add more entries to the lookup table.
Optionally, check User can edit records if you would like the user to be able to modify entries to the lookup table.
Optionally, check Unique records only if you want to avoid duplicate entries in the lookup list.
If you checked User can add records, make a selection from Form layout to edit records.
Optionally, change the selection in Allow Exceptions. The options are:
"Allow any value"
"Force closest match"
"Popup on mismatch"
"Allow any/fill only on popup"
Optionally, make a selection from Auto popup. Specify whether the Lookup window displays on demand or automatically. The options are:
"Do not automatically popup" - The Lookup window displays on demand. You must click the Pop-up smart button attached to the Lookup field. This is the default.
"Popup on entrance" - The Lookup window displays every time the cursor enters the field.
"Popup conditionally on entrance" - Build a conditional expression that determines whether the window displays automatically. For example, the Pop-up condition: ISBLANK("CUST_ID") causes the Customer Lookup window to appear only if the Cust_ID field is empty.
1. If you selected "Popup conditionally on entrance" in step 9b, enter an expression that defines the Popup condition. The expression must resolve to either TRUE (.T.) or FALSE (.F.). Click to display the Expression Builder to help you define the expression.
2. Optionally, select a value from the Position list to indicate where the Lookup window should appear. The listed positions are relative to the Alpha Anywhere Main Application window. The options are:
"Cascading" - displays the window just below the form window title, so that both title bars are visible.
"Custom" - lets you specify the position of the Lookup window in inches or centimeters. Indicate the distance from the upper-left corner of the layout window both horizontally (X) and vertically (Y).
"Sticky" - the popup remembers and reappears at its last position
3. If you selected "Custom" in step 9d, enter position values in the Custom X and Custom Y fields. Enter dimension values in the Custom Width and Custom Height fields.
4. Clear Allow maximized display if you want to prevent the popup dialog from being maximized.