Programming smarter Previous button

  • Thread starter Thread starter Asha
  • Start date Start date
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.
 
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.
 
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
 
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 .
 
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
 
Back
Top