question about command to save record

moradisndat

Registered User.
Local time
, 17:58
Joined
Mar 27, 2015
Messages
14
I've been looking at 2 lines of code in 2 different modules and it looks like they both do the same thing. Can someone tell me if there is any difference between these 2 lines of code?

DoCmd.RunCommand acCmdSaveRecord

versus

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
 
both work, but the second only relates to 2003 and earlier - effectively it is running the save action in the access menu bar.

Personally I would stick with the first one
 
Thanks for explaining the difference and for your quick reply.
 
DoCmd.RunCommand acCmdSaveRecord only works with the Current record. If you are updating data in a different form from the one you are in, you can do this by temporarily re-setting the focus to the other form - thus making it the current record.

Here's one I did earlier. In this example, we are updating a field in the FA02_Trans_Header form, but doing it from the FR21_MailTextType form. Just showing the relevant bit of code:

Code:
Forms!FA02_Trans_Header.SetFocus
Forms!FA02_Trans_Header!Subject = SubjectText
DoCmd.RunCommand acCmdSaveRecord
Forms!FR21_MailTextType.SetFocus
 
Last edited:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

was actually used by the Command Button Wizard, up through v2003, but its use has been deprecated since then, the fear/feeling being that MS will eventually stop supporting it, although it still works, as far as I know, and definitely works thru v2007.

DoCmd.RunCommand acCmdSaveRecord

or its brother code

If Me.Dirty Then Me.Dirty = False

are definitely the more preferred approaches.

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom