search key not found - but only when saving via button

Dear experts -
This is a little puzzling. I have a form. In the 'Save' button, i have, simply:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Now, if I save the record by pressing Shift Enter - it saves normally and gives no message.

However, if I save by pressing the above button, it also behaves properly BUT gives me the error message NO CURRENT RECORD. (if I am turning on the error trapping, it gives the message: "search key not found".

any idea what would cause this (data seem fine - I don't think there is any problem with the data) and does the message mean anything and if not, can I trap for it?
Who is Participating?
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 should not use that to save a record. Instead use either:

If Me.Dirty Then Me.Dirty = False


DoCmd.RunCommand acCmdSaveRecord

"DoMenuItem" has was replaced in Access 97 by the RunCommand method. DoMenuItem is included only to provide backwards compatibility. According to the MSDN article on DoMenuItem:

Some commands from previous versions of Microsoft Access aren't available in Microsoft Access 2000, and DoMenuItem methods that run these commands will cause an error when they're executed in Visual Basic. You must edit your Visual Basic code to replace or delete occurrences of such DoMenuItem methods.

This would apply to versions of Access AFTER 2000 as well, so take care when using these old commands.

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
Jeffrey CoachmanMIS LiasonCommented:
<No Points wanted>

Even if you look at this purely from a lazy man's standpoint, it is much easier to type (and remember:
    If Me.Dirty Then Me.Dirty = False
...than it is to type/remember:
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70


terpsichoreAuthor Commented:
thanks - and thanks to mr. coachman as well.
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.