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

saving a record

Status
Not open for further replies.

genxiii

Technical User
Jun 13, 2003
17
US
hey guys, i'm trying to save a record on a form even before the entire for is filled out. As soon as the primary key is filled out i want it to automatically save the record.

i'm running the code to save on the afterupdate event

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 'saves record

But i keep getting Runtime error '2501'
The domenuitem action was canceled.

it wasn't a problem before but it is now. i know its probably not liking some other code i have. ne ideas? thanks
 
In order to save the incomplete record, all the fields must pass the validation criteria implied by the table's Required properties and any validation rules defined in the table. The most likely cause of this error is that some field that hasn't been entered yet has Required = Yes in the table.

DoMenuItem is being deprecated. You should use RunCommand acCmdSaveRecord instead. That might also give you a different error message that helps identify the problem better.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Rick, i tried that code but got the same error. None of my fields are "required" except for the primary key itself.

 

I find it funny/ironic that the button wizards in
Access 97 generate the code using the DoCmd's as GenXiii shows, but looking at the Help for RunCommand, it says that DoMenuitem is only there for backwards compatibility.

So Since I wasnt aware of RunCommand, I now need to upgrade all my MenuItem code so it'll fit into Access2000/XP!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top