If you have a record number and want to retrieve the current record from this record number, you can use the GOTO RECORD command.
About Record Numbers
However, an error will be returned if you provide a non-valid record number. This can happen if you request record 5000 when your table does not contain any record with record number = 5000. The unique way to catch this error is to use an ON ERR CALL system. In this system, you can catch this error and set up some variables before resuming your code.
However, you may already have an existing ON ERR CALL system and might not want to modify it in order to handle this situation. In that case, there is another elegant way to do this by using a BOOLEAN ARRAY, and the commands CREATE SET FROM ARRAY and USE SET. Instead of using GOTO RECORD, you can create and use sets. If you test the set with RECORDS IN SET, you will notice that the created set is not empty. However, if you use the set, you may retrieve an empty selection if the record numbers are not valid.
CREATE SET FROM ARRAY([MyTable];$Array;"Myset")
If (Records in selection([MyTable])=0)
` The record number does not exist
` The records number is valid. The record has been retrieved