Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange instance with record pointer

Status
Not open for further replies.

amwprogg

Programmer
Jul 8, 2005
52
GB
Hi All.
I have a simple form that has a NEXT button for displaying
the next record. It initialises OK (displays the first record on file) then when you press the next button (which effectively just SKIP 1 and displays the next record) the pointer has gone to the record number AFTER the EOF. As soon as it fires the NEXT button CLICK it has set the pointer off the end of the file.
I cannot see why it is doing this. Has anyone had problems with this?
Andy.
 
I think you're describing normal xBase behaviour. You can demonstrate this from the Command Window.

If you open a browse window and type GO BOTT then the status bar will tell you you're on "Record 90 of 90" and EOF() will be .F..

Type SKIP. The status bar will tell you you're on "Record 91" and EOF() will be .T.. You have to fall off the bottom of the table before EOF() registers.

What you have to do is put a test for EOF() in your GoNext code and do a GO BOTT if EOF() is true.

Geoff Franklin
 
Andy,

For what it's worth, here's the code in my NEXT button:

Code:
SELECT MyTable
SKIP
IF EOF()
  SKIP -1
ENDIF
THISFORM.Refresh

and this is the PREVIOUS button:

Code:
SELECT MyTable
IF NOT BOF()
  SKIP -1
ENDIF
THISFORM.Refresh

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thanks Geoff, Mike.
I still don't know where the pointer is going past the EOF.
As soon as it hits the first SKIP it always throws up an error, but the pointer should be on the first record at that point.
Still, these things are sent to try us!
Andy.
 
Thanks to all who replied.
I discovered what was happening. The page with the NEXT button was part of a pageframe and an INIT in another page actually SCANNED the file concerned and left the pointer at the end of file.
Silly really.
Andy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top