lookupselected(
DATABASE
,
KEYFIELD
,
KEYDATA
,
DATAFIELD
,
DEFAULT
,
LEVEL
)

The lookupselected( function searches the selected records in a database for a value, then returns other information from the same record. For example, the lookupselected( function can look up a phone number given a customer name, or look up a price given a part number.


Parameters

This function has six parameters:

database – is the database that will be searched. This database must be currently open. If this parameter is "" then the current database will be scanned. Note: The lookupselected( function will search only selected records in the database, excluding records that are not currently selected. If you want to search all records, use the lookup( function.

keyfield – is the name of the field that you want to search in. For example if you want to look up all checks written to a certain vendor, this should be the field that contains vendor names. The field must be in the database specified by the first parameter. (Note: For compatibility with older versions of Panorama, you are allowed to quote this parameter, however, quoting is not necessary.)

keydata – is the actual data that you want to search for. For example if you want to look up all checks written to a certain vendor, this should be the actual vendor name. This parameter is often a field in the current database, but it could also be a variable, a constant, or a general expression.

datafield – is the name of the field that you want to retrieve data from. For example if you want to retrieve check numbers, this should be the name of the field that contains check numbers. This must be a field in the database specified by the first parameter.

default – is the value you want this function to return if it is unable to find the information specified by the keyField and keyData parameters. The data type of the default value should match the data type of the dataField. If the dataField is numeric, the default should usually be zero. If the dataField is text, the default should usually be "". Note: This parameter is optional. If it is omitted, the lookupselected( function will return an error if the search fails.

level – is the minimum summary level to be searched. Usually this parameter is zero so that the entire database will be searched. If the level is set to 1 through 7, only summary records will be searched. Note: This parameter is optional. If it is omitted, all records will be searched.


Description

This function searches a database looking for selected records where the keyField matches the specified keyValue. When it finds a match, it stops searching and returns the contents of the requested dataField from that record.


Note: To learn more about the theory and technical details about working with links between databases, see Linking with Another Database. The lookupselected( function can also be constructed automatically for you with the Relational Workshop wizard.


This function is exactly identical to the lookup( function, except that it only searches selected (visible) records instead of all records. See the lookup( for more information and examples.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but now the default and level parameters are optional. Also, you now are allowed to use "" to specify the current database.