Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Navigation Buttons don't stop at last record

Status
Not open for further replies.

ytorres

Programmer
Dec 26, 2003
13
PR
Hi,

I have a pop up form in which I am using the record navigation buttons. They read the correct amount of records there are in the form's query but the next button never turns gray when you reach the last record. If you click it again it tries to go to a record that still doesn't exists and obviously gives the user an error related with the missing key field. Please, can someone tell me why this is happening? I checked the form's properties against navigation buttons that do work and they are the same, i checked the query and it displays only the records correctly. I'm using Access 2000.

Thanks,
Torres
 
Thanks but I tried that and what it does it that it doesn't allow any new records and I need to be able to create new records but not with the next record button...
 
I would suggest turning OFF the default Access navigation buttons ( they're a horrible UI example, anyway) and use command buttons for Next and Previous. You can then code the NEXT button so that when it reaches the End Of File, it does NOT try to automatically add a new record. (Plus, you can code the PREVIOUS button so you don't get that ugly error message about trying to go 'before' the first record...")

Then have an ADD NEW button to add your new recs, and you're all set.

jmh


Don't be sexist - Broads hate that!

Another free Access forum:
More Access help stuff at
 
You'd have to create your own navigation buttons...each time checking to see if you're at the last record or not (and if so, disable the button). You would then also need a "New" button. Hope that helps.

Kevin
 
You can create your own record navigation buttons easily to do this, but I'm not sure about controlling the behavior of the default nav buttons.

If you are interested in creating your own buttons, you can do something like this:

Create a command button, and in its click event do something like this:

Dim rs As DAO.Recordset

On Error GoTo Err_cmdNextRecord_Click

Set rs = Me.RecordsetClone

If Me.CurrentRecord < rs.RecordCount Then
'Go to next record
DoCmd.GoToRecord , , acNext
Else
'We are on the last record, do nothing
End If


-Gary
 
Wow! Okay so I guess I have to the Navigation Buttons, :) Thanks for all the replies!

Torres
 
Wow, three at the same time...and all with the same info...that's pretty good.
 
Here's a tip that I use quite often concerning navigation buttons and reaching the 1st or last record. I don't use any code to check if EOF or BOF. Usually, by default, the &quot;OnError&quot; ends with something like this...

Err_Command24_Click:
MsgBox Err.Description
Resume Exit_Command24_Click

All I do is remove the MsgBox statement.

Err_Command24_Click:
Resume Exit_Command24_Click

Now nothing happens when at BOF or EOF [wink]

Gawd I love this Access stuff..too bad I don't know what I'm doing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top