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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On Last Record, don't allow 'Next' navigation to create new

Status
Not open for further replies.

ainkca

Programmer
Aug 26, 2002
111
CA
I'm using Access 97 and I have a form that's based on a table with an Autonumber field as the primary key.

I used the wizard to create buttons for First Record, Previous Record, Next Record, Last Record and New Record.

What I'd like to do is when the 'Next Record' button is clicked, have it check first to see if the current record is the last record and give the message 'You're at the end of the recordset' if it is. (Like it does when the primary key isn't an autonumber field. At least I assume that's why it behaves this way?)

Any suggestions?
Thanks in advance,
ainkca
 
something like

If rs.EOF = True Then

MsgBox ("Message")
Exit Sub

Else



David Lerwill
"If at first you don't succeed go to the pub"
 
The DataEntry property was set to yes (and still is), but thanks for the suggestion quietstormtw.

dwlerwill... I'm not familiar with EOF - trying to figure it out from the online help, but still struggling a bit. I will keep trying.

 
Oops, I need to correct that. I can't keep the DataEntry set to yes or the navigation buttons don't work. Users need to be able to go through existing records, or create a new record. What I don't want is for them to accidentally create new 'blank' records if they click the 'Next' button while on the last record.
 
DoCmd.GoToRecord , , acNext
If Me.NewRecord Then
DoCmd.GoToRecord , , acPrevious
End If


Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hey thanks! That works. Unless they click Next twice, and then it does add another record. I can't see them doing it twice though, especially if I put a message box in there that they're at the end of the recordset. Thanks very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top