Nav buttons msgbox popups

  • Thread starter Thread starter Mikie
  • Start date Start date
M

Mikie

I've seen it here before, but cannot find it, so if you
can point me in the right direction, I would be greatful.

I have nav buttons on my form, and I get those 'end of
recordset' pop ups. What I want to do is disable the nav
button if there is no 'next' or 'previous' record.

Thanks.
 
Hi Mikie

Test for going back:
If Me.CurrentRecord > 1 Then _
DoCmd.GoToRecord , , acPrevious

Test for going forward:
If Me.CurrentRecord < Me.Recordset.RecordCount Then _
DoCmd.GoToRecord , , acNext
 
Thanks Graham, that works better than what I had, but is
there a way to actually disable the buttons?

Thanks.
-----Original Message-----
Hi Mikie

Test for going back:
If Me.CurrentRecord > 1 Then _
DoCmd.GoToRecord , , acPrevious

Test for going forward:
If Me.CurrentRecord < Me.Recordset.RecordCount Then _
DoCmd.GoToRecord , , acNext

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I've seen it here before, but cannot find it, so if you
can point me in the right direction, I would be greatful.

I have nav buttons on my form, and I get those 'end of
recordset' pop ups. What I want to do is disable the nav
button if there is no 'next' or 'previous' record.

Thanks.


.
 
Mikie said:
Thanks Graham, that works better than what I had, but is
there a way to actually disable the buttons?

Certainly! In your Form_Current procedure, put the following code:

cmdPrev.Enabled = Me.CurrentRecord > 1
cmdNext.Enabled = Me.CurrentRecord < Me.Recordset.RecordCount

I think I would leave the tests in the Click procedures as well, just as a
"belt and braces" measure.
 
Hey I tried this, but I get an error message saying Variable not
defined. then it highlights cmdPrev

So I am lost, I did not realize needed to be defined, (Sorry, just
learning). How do you solve this?

Cheers
 
Hi Paul

cmdPrev and cmdNext are the names of the "Previous" and "Next" command
buttons respectively. Substitute your own names there.
 
Back
Top