Xbasic

KEY_EXIST Function

Syntax

Result_Flag as L = KEY_EXIST(C tagname,A keyvalue)

Arguments

tagname

The name of an index tag that may contain the Key_Value. The Index_Tag parameter can include a full drive and path specification. If you omit the drive and path, Alpha Anywhere searches the current directory.

keyvalue

A string constant, character variable, or an expression that returns a character value.

Description

Returns TRUE if a specified key value is found in a specified index.

Discussion

KEY_EXIST() returns .T. (TRUE) if Key_Value is found in index Index_Tag ; otherwise, it returns .F. (FALSE). This function is useful for checking if a record with a certain key value already exists in the primary table. Note : If you want to define a Validation Field Rule to prevent the entry of a duplicate record, use KEY_UNIQUE(), not KEY_EXIST().

Assume that the following table is indexed on the NAME field, and the index is stored under the tag name "NAMEORD".

Customer

Cust ID

Name

C100

InSync

C101

ACE Software

C102

Friendlies

C103

Sunstar

C104

Progress Inc.

C105

Adventure Holidays

? key_exist("NAMEORD", "InSync")
= .T.
? key_exist("NAMEORD", "Alpha")
= .F.

See Also