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

DoCmd versus RunCommand - differences?

Status
Not open for further replies.

BobJacksonNCI

Technical User
Mar 11, 2003
725
0
0
US
TIA!

I'd like to know the difference between DoCmd and RunCommand.

Background: I was asked if a Powerpoint presentation could be password protected. The answer is no, Powerpoint does not include that capability. But Access does. So I created an Access database with a designated startup form and On Open event code shown following this dialogue. (Works perfectly.) Note that I commented the line beginning with RunCommand. That line is interchangeable with the following line - DoCmd.RunCommand. Since I'm hoping this isn't my last assignment, I wondered what the differences are. I.E., which situations call for DoCmd and which call for RunCommand. Understanding will shorten my searches in Help and in Microsoft's knowledgebase.

Dim retval As Double

retval = Shell("c:\program files\microsoft office\office\powerpnt.exe f:\rjackson\Projects\MISCELLANEOUS\vestalnewhire.ppt", 3)

'RunCommand acCmdClose 'CLOSE THE ACCESS APP

DoCmd.RunCommand acCmdClose 'CLOSE THE ACCESS APP

DoCmd.Quit 'QUIT ACCESS
 
DoCmd.RunCommand acCmdClose runs the Access menu option to quit the database.

DoCmd.Quit uses VBA to initiate a shutdown.

Both have the same effect in this particular case. In general, RunCommand is for running non-database specific tasks such as simulating menu clicks. DoCmd will generally run database-related tasks. Type each word within the VBA editor followed by a '.', then scroll down the intellisense list to see the available functions/parameters.
 
Thank You! - for the speedy and concise explanation.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top