Enables setting of keys and ranges for a dataset prior to a search.procedure SetKey;DescriptionCall SetKey to put the dataset into dsSetKey state and clear the current contents of the key buffer. The FieldByName method can then be used to supply a new set of search values prior to conducting a search.Note: To modify an existing key or range, call EditKey. with Table1 dobegin SetKey; FieldByName('State').AsString := 'CA'; FieldByName('City').AsString := 'Santa'; GotoNearest; end;
Moves the cursor to a record specified by the current key.function GotoKey: Boolean;DescriptionUse GotoKey to move to a record specified by key values assigned with previous calls to SetKey or EditKey and actual search values indicated in the Fields property.If GotoKey finds a matching record, it positions the cursor on the record and returns True. Otherwise the current cursor position remains unchanged, and GotoKey returns False.The following code uses the EditKey and GotoKey methods to move to a particular record on Table1. The actual field values are not changed when making the assignments because of the call to EditKey.with Table1 dobegin EditKey; FieldByName('State').AsString := 'CA'; FieldByName('City').AsString := 'Santa Barbara'; GotoKey;end;
with Table1 dobegin
SetKey;
FieldByName('State').AsString := 'CA';
FieldByName('City').AsString := 'Santa';
GotoNearest;
end;
EditKey;
FieldByName('State').AsString := 'CA';
FieldByName('City').AsString := 'Santa Barbara';
GotoKey;end;