-
detecting EOF/BOF
i've made my own little kind of ADO data control with 2 buttons (previous & next) and a textbox to display the ID of the record. is there anyway i can detect if, when the user clicks Next and moves to another record, that the record following this record is the EOF marker, so that i can disable this button, and vice-versa for the Previous button? at the moment i'm using an error handler, so that when they hit the EOF marker, it drops in to the error handler and disables the button, but this seems like a pretty dodgy solution.
-
Suppose 'Rs' is our RecordSet.
Code:
if Rs.EOF = True then
msgbox("You reached EOF!"),vbinformation
end if
same for previous:
Code:
if Rs.BOF = True then
msgbox("You reached BOF!"),vbinformation
end if
-
thanks, but that's not quite what i need. i found another way of doing what i have already, by using AbsolutePosition, but i need to know if the record they're currently on is the one just before the EOF marker, rather than knowing if they've just reached the EOF marker.
-
That's easy: when you press "Next", instead of moving one position, move TWO positions. If the current record says "EOF", move back one position and disable the "Next" button. If it doesn't, move back one position and enable the "Next" button. It's that easy ;)
-
good idea :) although that may slows things up a bit, and it's already running fairly slow. i might just stick with disabling it when they reach EOF. thanks for the suggestions though :)
-
<?>
Code:
Private Sub checkbtns()
'
' Check for button positions
'
rs.MovePrevious
cmdPrevious.Enabled = Not (rs.BOF)
rs.MoveNext
'
rs.MoveNext
cmdNext.Enabled = Not (rs.EOF)
rs.MovePrevious
'
End Sub