Nav buttons msgbox popups

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.
 
G

Graham Mandeno

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
 
M

Mikie

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.


.
 
G

Graham Mandeno

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.
 
P

Paul Byford

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
 
G

Graham Mandeno

Hi Paul

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top