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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End-of-File won't show true

Status
Not open for further replies.

gshurman

Programmer
Oct 27, 2001
25
US
I have a simple table that is part of a database. I've created a form with a couple of fields from the table and the navigation controls from the FFC.

The first, last and previous buttons work as they should. The next button works correctly until it reaches end-of-file. After displaying the last record, if I click next again it goes to the record that is 1 record before the last record. EOF() is never true. There are only 3 records in the file. I've browsed the file and did a COUNT and there are only 3 records.

This only happens with this one form and table. All other tables and forms in the application work OK. I've recreated the table under a different name and re-entered the data. I've tried it as a free table. I'm using VFP 9 SP1. I tried it under VFP 6 with the same result.
 
I'm using the plain old Visual FoxPro Foundation Class. I've tried using:

IF EOF()
GO BOTTOM
ELSE
SKIP
IF EOF()
SKIP -1
ENDIF
ENDIF
THISFORM.REFRESH

 
I test for eof like this

If .not. eof()
skip
else
*dont move the pointer
endif
thisform.refresh()
 
Your code seems ok, but can do the following to debug the problem, change

thisform.Refresh with thisform.txtControlName.Refresh
i.e. do not refresh the whole form.

txtConrolName is a text box, and its ControlSource is pointig to the FieldName of your Table.

disable relation(s) if any.


try it.


Nasib Kalsi

 
Gshurman,

Yor code looks OK. It's slightly more complicated that it needs to be, but that affect the issue. The following would do the same thing:

Code:
SKIP
IF EOF()
  SKIP -1
ENDIF
THISFORM.REFRESH

The only thing I can think of is that you have a deleted record at the end of the table, or there is a filter in force and the last record doesn't meet the filter. Either way, it would mean the behaviour you are seeing is correct.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
White,

Your code isn't quite correct:

Code:
If .not. eof()
   skip
else
    *dont move the pointer
endif
thisform.refresh()

If the pointer is on the last record, your code would move it to EOF, which generally isn't what you want (the user will just see blank fields).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike, I do see the blanks..
Your code works much better!
 
Mike:

I think the original code from gshurman is good, if you replace skip -1 with go bottom. This will take care of empty file as well and not produce an error.

IF EOF()
GO BOTTOM
ELSE
SKIP
IF EOF()
go bottom && *** not SKIP -1 ***
ENDIF
ENDIF
THISFORM.REFRESH


Nasib Kalsi

 
Nasib,

Yes, I agree with you.

I wasn't saying that GShurman's code wasn't right. I was saying that the presence of deleted or out-filtered records might explain why he/she thought it was going to the wrong record. (But, on reflection, I'm not completely sure about that.)



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks all. I think everyone is missing the point. The same problem exists when I use the VFP Foundation Class for record navigation in both VFP 6 & 9. I've recreated the table as both a free table and as part of the database with a different name and entered the records again to test. I've tried it with and without indexes and nothing is filtered. A number of other tables in the database work as expected.
 
Mike:

You are right.


GSHURMAN:

Please try this in the init of the form

* Init of the form
* trouble.dbf is a standalone table
*
use trouble exclusive alias trouble in 0
select trouble
copy to tmp
zap
appe from tmp

* if still the same problem
* then uncomment the next 2 lines
* close data
* use tmp alias trouble
*
* Then on the form create a CommandButtonNextAsIs
* Insert the code as you have it posted here, without change.
*
* Add one more CommandButtonMike on the form
* (Insert the code in click event as from Mike's
* Suggestion, but change skip -1 to go bottom,
* (will not make any difference - for debugging only))
*

* Also add ffc class drag _datanavbtn and _navbtn

* At this point you have 4 NEXT BUTTONS on the form.

* First Try CommandButtonMike
* Then Try CommandButtonAsIs
*
* Then Try _datanavbtn
* does Next Button Disabled at the end of file ?
*
* Then Try _navbtn
*
******* Post the results *****
*


try it


Nasib Kalsi


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top