Question DoCmd.DoMenuItem

marvil

Registered User.
Local time
Today, 13:26
Joined
Oct 16, 2013
Messages
24
I was asked to complete the VBA code in an incomplete Access database.

I found the following line of code which means to save the current record:
Code:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

I am using Access 2010. Would it not be better to write it this way?

Code:
DoCmd.RunCommand acCmdSave
 
It should be DoCmd.RunCommand acCmdSaveRecord.
 
Sorry to leap in, but I've found

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70

in a database I'm looking at for someone else.... can anyone tell me what it does, and what I can replace it with?


(it's on a button that prints a report from a form, before docmd.printout acSelection , so is it something to do with selecting the current record? )
 
ok, that makes no sense at all, in the context of what is happening on the form, lol..... maybe that's why it's not working as it should ;)
 
To select Record, based on the Document it should be 9.. However when playing around in the immediate window, the acSelectRecord comes out to be 8.. I am a bit at loss.. Sorry !
 
DoMenuItem was deprecated more than a decade ago and should not be used at all in a new project.

DoCmd.RunCommand.Save is meant to save the design not the record.

Records can be saved with:
Me.Dirty = False
 
the database I'm working on was originally written on Access 2000 but I'm going through it trying to 'update' it, which is why I'm coming across all this old code..... trying to decipher it all isn't proving that easy!
I also keep finding things like this:
Code:
If Me.OpenArgs = "GotoNew" And Not IsNull(Me![TypeID]) Then 
Docmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
in various places.... been trying to work out what that one does as well!! I thought it might just be a 'go to new record' but I can't fathom these DoMenuItems, lol....
 
yeah, that sounds about right - I think it must be some kind of 'catchall' in the coding so that when you open a form that's supposed to go to a new record, it definitely does, lol.... I've changed the code anyway to

DoCmd.GoToRecord , , acNewRec
 
Code:
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70

if the commands constants are zero based then I assume 8 refers to acDelete
 

Users who are viewing this thread

Back
Top Bottom