Including Control Values in Lookups

Values from controls on a Smart Form can be used as part of the lookup query.  Only values from the same logical section may be used.  For instance, a value in a control in the header may be used with a lookup in the header, but not in a detail line.  Detail line lookups can use values only from the specific line.  There is no limit to the number of control values that can be used.  The general form of an ad hoc sql statement that uses control values is as follows:

SELECT [fields] FROM [table] WHERE [field] = ‘<ControlName.ValueProperty />’ AND [field2]= ‘<ControlName2.ValueProperty />’ … ORDER BY…

 

This is just typical sql statement, but the lookup engine will substitute the specified control value in the section between the angle brackets.  To drill a little deeper:

·        '<ControlName.ValueProperty />'

Values that should be treated at text in SQL need to have single quotes OUTSIDE of the angle brackets. 

·        <ControlName.ValueProperty />

These brackets indicate that everything inside and including the brackets should be replaced by the value in the control.


Lookup Configuration

Lookup SQL Statement Syntax.htm