Next & Previous

  • Thread starter Thread starter James
  • Start date Start date
J

James

Hello I have a form and I have a next and Previous button
on my form and what I would like to do is to gray out the
previous button when there are no records to go back to
and have the next button enabled only. Then when it hits
the last record the next button is grayed out indicating
to the user that there are no more records to view.

How can I achieve this?

Many Thanks

James
 
When you move forward, check for Me.Recordset.EOF;
backwards, Me.Recordset.BOF
Disabling the control in question (setting its Enabled property to False)
will cause it to "gray out".

HTH
- Turtle
 
Hello I dont have the below code. What does the below code
do? and is there a way I can do what I originaly asked?

Many Thanks

James
 
Hello, yourself!

If you're not able to write the necessary code from my suggestions (or even
tell that my suggestions would give you the result you want), you probably
need to consider either undertaking some serious learning (perhaps a
community college course?) yourself, or hiring a professional to do the job
for you.

HTH
- Turtle
 
Hello,

Look all I need is the code for this I have an idea of
what it is this is why I am asking so I can compare my
idea to the proper code to see if it matches...

I think the code is something along the lines of:

cmd1 = Next Button
cmd2 = Previous Button

*Code Starts*

If ID < 1 Then
cmd1.enabled = False Else
cmd1.eabled = True
End If

If ID = *Need end of record code here* Then
cmd2.enabled = False Else
cmd2.enabled = True
End If

*Code Ends*

Hows the above... This is all I need the little bit of
code to say the end of the records.... also is my Code
correct is also what I am asking for assistance on...

Many Thanks

James
 
I do not know what your variable ID is, how it is determined, or what its
maximum value would be.
If it is a field in a table named MyTable, you could find its maximum value
by
DMax("ID","MyTable")
However, unless your form uses a recordset which is explicitly sorted on the
ID field, there is no assurance that the last record in the recordset will
hold the highest value of ID.
(In fact, there is no assurance that the first record in your recordset
will have a value less than 1 in the ID field.)

Your form's recordset can be referenced programmatically as Me.Recordset.
When your form is diplaying the first record of its recordset,
Me.Recordset.BOF (for Beginning of File) is true;
When your form is diplaying the last record of its recordset,
Me.Recordset.EOF (for End of File) is true.
This is what I was suggesting that you test in my original reply.

HTH
- Turtle
 
Back
Top