Programming smarter Previous button

A

Asha

can someone give me an example of how I would program a
previous button to disable or go gray when it is at the
first record? I found some sample code to do the next,
but I don't know enough about Access and vba to know if it
can tell when you are at the first record.

Thank you.
 
J

Jeff Williams

In the next example, it is probably using EOF to identify that it is at the
end. You can use BOF to determine if you are at the beginning.
 
A

Asha

here is what it used in VBA. I tried FirstRecord, but I
got a compile error so I figure that is incorrect.

If Me.NewRecord = True Then
Back.SetFocus
GotoNextRecord.Enabled = False
Else
GotoNextRecord.Enabled = True
End If
 
D

Dirk Goldgar

Asha said:
can someone give me an example of how I would program a
previous button to disable or go gray when it is at the
first record? I found some sample code to do the next,
but I don't know enough about Access and vba to know if it
can tell when you are at the first record.

Thank you.

I've written these upon occasion, using various form properties to
determine the enabled state of the buttons. I can't lay my hands on one
at the moment, but it seems to me you should be able to use the form's
CurrentRecord property to tell if you're on the first record.

Stephen Lebans has posted in the past that he has a complete set of
navigation controls on his web site: www.lebans.com .
 
H

Hugh O'Neill

Asha said:
can someone give me an example of how I would program a
previous button to disable or go gray when it is at the
first record? I found some sample code to do the next,
but I don't know enough about Access and vba to know if it
can tell when you are at the first record.

Thank you.


As well as all the other suggestions, you will find the code for this
and copy/pasteable solutions in the Access [version] Developer's
Handbook along with lots of of other magic spells!

hth

Hugh
 

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