SET KEY Command
| Visual FoxPro 9.0 SP2 |
| SET KEY Command |
| See Also |
|
Specifies access to a range of records based on their index keys.
SET KEY TO [eExpression1 | RANGE eExpression2 [, eExpression3]] [IN cTableAlias | nWorkArea] |
Parameters
- eExpression1
-
Allows access to a set of records with identical index keys. eExpression1 is a single index key value. All records with index keys that match eExpression1 are accessible.
- RANGE eExpression2[, eExpression3]
-
Allows access to a set of records with index keys that fall within a range of index key values. eExpression2 allows access to records with index keys equal to or greater than eExpression2. eExpression3 (preceded by a comma) allows access to records with index keys equal to or less than eExpression3. Including both eExpression2 and eExpression3 (separated by a comma) allows access to records with index keys equal to or greater than eExpression2 and equal to or less than the eExpression3.
For example, the CUSTOMER table includes a character field containing postal codes. If the table is indexed on the postal code field, you can specify a range of postal codes with SET KEY.
In the following example, only records with postal codes falling within the range of 40000 to 43999 appear in a Browse window:
Copy CodeCLOSE DATABASES USE customer SET ORDER TO postalcode SET KEY TO RANGE '40000', '43999' BROWSE
- IN cTableAlias| nWorkArea
-
Allows access to a range of records for a table open in a specific work area. cTableAlias specifies the work area alias and nWorkArea specifies the work area number. If no table has the alias you specify, Visual FoxPro generates an error message. If you omit the work area alias and number, SET KEY operates on the table in the currently selected work area.
Remarks
See Also
© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic
Microsoft Visual FoxPro 9 SP2 Help file, VFPX Edition v1.08