Disabling "Previous" button

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I have figured out how to disable the "Next" button if
Me.NewRecord = True but how do I disable the "First"
and "Previous" buttons if the form is currently showing
the first record. There is no Me.FirstRecord!!

Thanks for the help..
 
-----Original Message-----
I have figured out how to disable the "Next" button if
Me.NewRecord = True but how do I disable the "First"
and "Previous" buttons if the form is currently showing
the first record. There is no Me.FirstRecord!!

Thanks for the help..
.

If Me.RecordsetClone.BOF = True
 
One way might be to establish 2 variables that equal the bookmark values of
the first and last records of your form's recordsetclone. Then, in
Form_OnCurrent event, compare the current Me.Bookmark value to those
FirstRec and LastRec variables and react accordingly.

Remember to update FirstRec and LastRec after any requeries, sorting,
filtering, additions or deletions.

Hope this helps
 
I have figured out how to disable the "Next" button if
Me.NewRecord = True but how do I disable the "First"
and "Previous" buttons if the form is currently showing
the first record. There is no Me.FirstRecord!!

Here's some sample code that you can glean what you want from:

'**********SAMPLE START
With Me.RecordsetClone
If Me.NewRecord Then
cmdGoToNext.Enabled = False
cmdGoToLast.Enabled = True
Me.cmdAddNew.Enabled = False
Else
.Bookmark = Me.Bookmark
.MoveNext
cmdGoToNext.Enabled = Not .EOF
cmdGoToLast.Enabled = Not .EOF
Me.cmdAddNew.Enabled = True
End If
If Not Me.NewRecord Then
.Bookmark = Me.Bookmark
.MovePrevious
cmdGoToFirst.Enabled = Not .BOF
cmdGoToPrevious.Enabled = Not .BOF
Else
cmdGoToFirst.Enabled = True
cmdGoToPrevious.Enabled = Me.NewRecord
End If
End With
'**********SAMPLE

This is likely not my most recent version of this code, but it was readily
available. <g>
 
Not to be picky, but I think the question was how to tell if you are
currently ON the first record.

BOF will be False if you are on the first record, or *any* other record.

It will only be True when you are currently positioned *prior* to the first
record. The poster is evidently trying to prevent users from being able to
do this by disabling the "previous record" button while on the first record.
 
Back
Top