I have started to program a database app using DAO. I am not using the MS data control object.
I want to have a form that will scroll through the records from a table using a next button and previous button. I had thought that it would be nice to disable the previous button when I am on the first record, and disable the next button when I am on the last record.
To do this, I would expect to use the BOF and EOF properties of the recordset. But it seems that these conditions only report true when you attempt to move before the first record and past the last record respectively; in other words, you have to attempt to move beyond the ends before it will tell you that you at the ends.
BOF and EOF conditions are only met when you are before the first record or after the last record. For example, If you are on record one and move back, you hit BOF.
To do what you want try using the RecordSet’s AbsolutePosition property in conjunction with the RecordCount property.
Note, though, that if you have a dynaset or snapshot type recordset the RecordCount property only shows the records you’ve visited. You can fix this by using a .MoveLast, .MoveFirst after you open the recordset.
It’s been a few years, but I wrote a vb program like that. I can’t remember which
solution I used but two come to mind.
3 counters: first counter is incremented to read/show the the record. The second is incremented 1 ahead and looks for eof. the third is incemented(decremented) -1 to look for bof.
2 For/ next loop used to count/read all records at start of program. Value of variable that is used to store the number of records is passed a variable that is used to initialize a dynamic array. Use array parameters to enable disable or buttons.