Access commit data to table as if user had clicked the next "New" record in a tabular form

Hi. In Access I want to commit data to table as if user had clicked the next "New" record in a tabular form. What VBA would I use?
I already tried to move to the next record with the following code but I got an error saying that I could not move to the next record.

DoCmd.GoToRecord , , acNext

Open in new window


1
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
PatHartmanCommented:
There are several commands that will save a record as a byproduct but it is always best to use the explicit command to avoid unwanted side effects.

DoCmd.RunCommand acCmdSaveRecord
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You don't have to do anything to commit your data, assuming your form is Bound. Access will simply save the data for you.

If you're trying to move to the Next record, and you're on the last record of the dataset, you'll see that error.
0
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
hi Murray,

> "I already tried to move to the next record with the following code but I got an error saying that I could not move to the next record"

my guess is that there is something in the table design* or validation on form BeforeUpdate** that is preventing the record from being saved, so Access cannot goto another record without fixing the issues or undoing what has been typed.

* are there fields marked as Required ? Are there foreign keys with a default value such as 0 (zero) that are not being filled with a value that actually matches something?

** is there any code in the form BeforeUpdate event?

have an awesome day,
crystal
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks for the help
0
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you're welcome, Murray ~ happy to help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.