Next and Previous buttons

G

Guest

I would like to disable the next button and previous buttons when certain
conditions are me in a form. The conditions are disable next when when on a
new record and disable previous when on the first record. I am using Access
2002. I tried this code.

Private sub form_current( )

if me.newrecord = true then
cmdprevious.setfocus
cmdnext.enabled = False
else
cmdnext.enabled = true
end if
end sub

I get an error after the else at cmdnext.enabled = true please help!
 
A

Allen Browne

Try:

Me.cmdNext.Enabled = Not Me.NewRecord
Me.cmdPrevious.Enabled = Not (Me.Recordset.AbsolutePosition <= 0)
 
F

Fred Boer

Dear RG:

There are a number of different ways to do this, and perhaps better
programmers than me will outline some of them for you. You might also try a
Google groups search using the term "disable navigation button", which I
just tried and which brought up relevant records.

BUT...

If you want, there is a complete, free solution available here:

http://www.lebans.com/recnavbuttons.htm

This is a subform you can just drop into your form and it will give you what
you need.

HTH
Fred Boer
 

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