Article ID: 147169
Article Last Modified on 9/30/2003
LOCAL lnRecNumber
SELECT Labels
**********************
* Save record Number *
**********************
lnRecNumber= IIF(EOF('Labels', -1, RECNO('Labels'))
SELECT * FROM LABELS &&Or any processing
************************
* Restore record Number*
************************
IF lnRecNumber > 0
GOTO (lnRecNumber)
ELSE
GO BOTTOM
SKIP
ENDIF
In this example, the negative number -1 is used to flag the end of the file
(EOF). However, using this approach might not yield the expected results
when you work with local views or when buffering is enabled.
SET EXCLUSIVE OFF
CREATE TABLE TEST (cName C(10))
SET MULTI ON
=CURSORSETPROP("Buffering",5)
WAIT WINDOW "Appending Data" NOWAIT
? "Record number before the data is committed"
=AddRec("Name 1")
=AddRec("Name 2")
=AddRec("Name 3")
WAIT WINDOW "Commiting the Changes" NOWAIT
=TABLEUPDATE(.T.)
WAIT CLEAR
?
? "Record number after the data is committed"
SCAN
? "Record Number:"
?? RECNO()
ENDSCAN
FUNCTION AddRec
LPARAMETER cName
INSERT INTO test VALUES (cName)
? "Record Number: "
?? RECNO()
lnRecNumber= IIF(EOF('Labels', -1, RECNO('Labels'))
can be changed to:
lnRecNumber= IIF(EOF('Labels', .NULL., RECNO('Labels'))
You can use the ISNULL() function to verify whether the record pointer is
at the end of the file. For more information about ISNULL(), search for
ISNULL() in the Help file.
Additional query words: VFoxWin
Keywords: kbcode KB147169