I have a browse procedure on a file ordered by a multi component key
MyFile FILE,DRIVER('TOPSPEED') ......
MyKey KEY(TBL:AreaNumber,TBL:ItemId),DUP,NOCASE,OPT
Record RECORD,PRE()
AreaNumber LONG
ItemId LONG
....
I’m trying to use locator class to be able to locate first record with a given AreaNumber and ItemId, but it only seems to work for single component keys. How can I locate a record and positon the browse cursor on the first last matching entry
If I remember correctly, the locator use the last component of the key (here ItemId field), so you have to assign a value to the previous components of the key (here AreaNumber field) and to the locator (here ItemId field).
I don’t have any Apps to look at, but I am pretty sure you can find something related to “free element” or something like that when using multi-part keys. It might be in the locator template prompts. But you can definitely set which element to locate on somewhere in there.
When you come back from an Add Form (InsertRecord) the Browse locates to the last record inserted, then reloads the Queue from there. I find that code. I think in ABC that’s Browse .ResetFromAsk().
I would setup 2 ENTRY on the Window for your 2 parts (Area and ID) plus a Locate Button. So the user has to type the 2 values then press Locate.
When the Locate button is pressed prime the record from your 2 ENTRY values for a SET(MyKey,MyKey) and NEXT(MyFile). That will load the first record that matches, or close enough. Check IF ErrorCode() mean end of the file was reached so
Now you have a record that matches Area and ID (or is right after) so refresh the browse as is done after an Add on the Form.