SCRLookUp()
Opens a database found in your CAPITAL company directory and presents a look-up box that allows users to search through the database.
Syntax
SCRLookup(<cTable>, [<cField>], [<nPasteFrom>], [<nSort>], [<cTitle>], [<cScope>], [<lRecord>], [<aFields>], [<aHeadings>] )
Arguments
<cTable> --> The name of the database table to open.
<cField> --> Any selection made from this table will be pasted into this field. If this is not specified pasting will be disabled.
<nPasteFrom> --> The column number to paste from.
<nSort> --> The default sorting order to present the table in.
For
most standard tables this setting will be ignored as the last user sort selection will be used by default.
You can override this behaviour by supplying an aFields parameter list.
<cTitle> --> The heading to appear at the top of the look-up box.
<cScope> --> The scope (range) of the look-up box's contents.
<lRecord> --> If TRUE is passed, the record number is returned.
<aFields> --> An array of column field names to pass to the look-up box. If not passed, the default set of columns are used.
<aHeadings> --> An array of column field headings to pass to the look-up box. If this parameter is not passed, default field names are used. If this parameter is passed, the number of column headings must match the number of field names passed in aFields.
Returns
Returns TRUE if the database was successfully accessed, unless lRecord = TRUE. If lRecord = TRUE, the selected record number is returned. Otherwise zero is returned if no record was selected.
Description
This function will open any available database table and allow a user to search it. It is also possible to paste a selection from this table into a field on the current screen.
The presented table will be displayed as a series of rows and columns. <nPasteFrom> indicates the column number that any pasted data will be extracted from. For this to work, <cField> must exist on the current screen.
Use <nSort> to control the current sort (presentation) order of the data in the table. This parameter will only apply if the table being opened has been sorted at least once.
A <cScope> may optionally be specified and this must correspond to the sort order. For example, if the table is sorted by name, the scope could be specified as "A", in which case only names beginning with "A" would be included on the list. The scope may only be applied to the selected sort order and must match the sort order type. In other words, if the sort order is numeric then the scope must also be numeric, otherwise a data type error will be reported by the system. Scopes should be applied to fields that are sorted in ascending sequence.
Examples
SCRLookUp() is useful as triggered event from a button press. For example, this script code accesses the table REGO when the button next to the field "Rego" is pressed:
If ButtonPress
ScrLookUp("Rego", "Truckno", 1)
Endif
This example returns a record number:
* Return Record Number
Declare nRecord Type Number
If ButtonPress
nRecord := ScrLookUp("Custrec", "Location", 1,,,, TRUE)
If nRecord == 0
Echo("Nothing selected.")
Else
Echo("Selected Record: " + Str(nRecord, 4))
Endif
Endif
![]() |