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

Stopping NextRecord Procedure from adding a new record.

Status
Not open for further replies.

dkmidi

Technical User
Mar 13, 2002
47
CA
Hi,

How do I stop the next record procedure to only go as far as the last record and not add a new record. I find when it adds a new record but I have no info for the new record, when I exit it deletes a number from my autonumber count!! then I have to go and resequence the whole darn thing again which is a pain.

So far this is the basic sub:

Private Sub GoTo_Next_Record_Click()

DoCmd.GoToRecord , , acNext

End Sub

Any help would be great!! Thanks,

Derek

ps. btw anyone know how to remove the bottom status/rec navigation bar?
 
Hi Derek!

One possibility is in the before update event of the form check the textboxes and, if they are blank, or if the data is incomplete then say Me.Undo. You may want to give the user a message box letting them know that it isn't being saved because the data is incomplete. To get rid of the navigation buttons, go to the form's property window and on the Format tab there will be Navigation Buttons, change the yes to no.

hth
Jeff Bridgham
bridgham@purdue.edu
 
try doing:

Private Sub cmdNext_Record_Click()
On Error GoTo NextError
DoCmd.GoToRecord , , A_NEXT
If IsNull (pick some primary key) Then 'you have to keep the parenthesis
Call cmdPrevious_Record_Click
End If
NextExit:
On Error GoTo 0 'that's the number
Exit Sub
NextError:
GoTo NextExit
End Sub
 
Hey guys thanks for all your pointers!

But I'm not really a programmer so you'll have to walk me through your code sinhluk!

Thanks!

Derek
 
basically the previous suggestion is telling you to create a "Next" button and put the code for the "On Click" event It is basically saying that if the value is null, then go back to the previous record.
 
You should be able to remove the navigation buttons in the format tab of the properties section of the form.(set navigation buttons property to "no")
As for your code problem, I am having the same problem. I am trying to do something like this:
(this is incomplete code, "eof" stands for end of file)
If recordset.eof then
.moveLast
else
.MoveNext
end if

I know how to do it with a recordset in VB but am having problems with it in Access as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top