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

how do i prevent gotorecord acnext adding a new record

Status
Not open for further replies.

jeffmoore

Programmer
Aug 29, 2003
301
US
i have a navigation button that uses gotorecord acnext function. only when i get to the last record it adds a record to my table. how do i prevent this from happening.
tia
jeff
 
You want to do a test for EOF. When EOF is reached, simply move to the previous record.

Also, is this form used to add new records or just to browse? If it is just for record browsing, in the properties, set Additions to no.
 
It is not adding any record it just has a new record display so you can enter a new record. as long you do not add info this record will be empty and is not considered part of the table.

After you need to have a place were to enter your next record. If you will run a Dcount on your table you will see that the last record is not in the count.
 
After a great deal of searching and tying many different things, I found the code below as a way to stop at the last record.

Dim intNewRecord As Integer

Forms![Wine SF1]![sf-Wines].SetFocus
DoCmd.GoToRecord , , acNext
intNewRecord = IsNull(Forms![Wine SF1]![sf-Wines]![WinesID])
If intNewRecord Then
DoCmd.GoToRecord , , acLast
MsgBox "You are at the Last of Record!"
End If

The 'Wines' are my Forms and Tables.

I hope this helps.
 
Wissoftware
I did a search of posts, to solve a similar problem, and really appreciated finding your solution. It really did the trick.

I'm glad they keep these posts around for a while.

Tom

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top