LOOKUP( ) Function

Example   See Also

Searches a table for the first record with a field matching the specified expression.

Syntax

LOOKUP(ReturnField, eSearchExpression, SearchedField [, cTagName])

Returns

Character, Numeric, Currency, Float, Integer, Double, Date, DateTime, or Logical

Arguments

ReturnField

Specifies the field whose contents LOOKUP( ) returns when the search is successful. If the search is unsuccessful, LOOKUP( ) returns an empty character string of the same length and data type as ReturnField.

eSearchExpression

Specifies the search expression. The search expression is usually the contents of a field in the table, or it can correspond to the index expression of the active index or compound index tag.

SearchedField

Specifies the field to search. If the table doesn't have an active index, LOOKUP( ) performs a sequential search through the field specified with SearchedField.

If an index file or index tag is open whose index key expression is the search field you specify, LOOKUP( ) uses the index file or index tag to perform a faster search.

cTagName

Specifies the name of a compound index tag for LOOKUP( ) to use in the search. A compound index search is the fastest search LOOKUP( ) can perform.

Remarks

If the search is successful, LOOKUP( ) moves the record pointer to the matching record and returns the contents of a specified field in the record.

If the search expression isn't found, LOOKUP( ) returns a blank character string the same length and data type as ReturnField. The record pointer is positioned at the end of the file.

If LOOKUP( ) is used to search a parent table, record pointers in all related child tables are moved to the related records.

This function can't be optimized with Rushmore.