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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.