BOF and EOF

  • Thread starter Thread starter max
  • Start date Start date
M

max

Hi all,
may be it is easy but I'm not that good...
I have this code in the OnCurrent event of the form to disable the Previous
Button on the nav bar if the current record is the first in the recordset:

'----- start of code ---------------
If Me.Parent.RecordsetClone.RecordCount = 0 Then 'we need to check if there
are NO RECORDS. If so,
Me.cmdNext.Enabled = False 'we disable
all buttons except for the <New> button.
Me.cmdPrev.Enabled = False
Me.cmdLast.Enabled = False
Else
Me.Parent.RecordsetClone.Bookmark = Me.Parent.Bookmark 'Synchronise
the current pointer in the two recordsets
With Me.Parent.RecordsetClone
'If there are records, see if we are on the first record
.MovePrevious
'If so, we should disable the <First> and <Prev> buttons
If .BOF Then
Me.cmdHidden.SetFocus
Me.cmdPrev.Enabled = False
Exit Sub
End If
End With
End If
'----- end of code ---------------

the question:
how is it possible to add at the end of this procedure a similar feature to
disable the Next Button on the nav bar if the current record is the last in
the recordset? Or may be I have to write it in a different procedure?

Thanks a lot,
Max
 
You may want to take a look at the AbsolutePosition property of the
recordset and compare it to the RecordCount of the recordset.

To continue with what you have, set the Bookmark, do a MoveNext, if you're
at the last record then EOF should have just become true.
 
Thnaks Wayne for the tip. Modifying what I already have now it works, but
since I will use this form as template to build other forms in the future, I
really like to do it in the best way possible, so if I've understood
correctly and this absolute position property is better, than I'm going to
investigate how to use it.

Thanks a lot :)
Massimo
 
Back
Top