Access VBA Macro Programming

(Joao Candeias) #1
The parameters are all optional:

 PrintRange An acPrintRange constant specifying the range to print—the default is
acPrintAll.
 PageFrom The page number to print from. This is required if you use acPages for
PrintRange.
 PageTo The page number to print to. This is required if you use acPages for
PrintRange.
 PrintQuality An acPrintQuality constant to specify print quality—the default is
acHigh.
 Copies The number of copies required. The default is 1.
 CollateCopies True (default) or False.

Quit


Quitis used to quit the Access application. The syntax is:


DoCmd.Quit(Options)


Options is an optional argument and is an acQuitOption constant. The default is
acQuitSaveAll. If a user has added a filter to a form, there is a danger that this will
be saved, which means when other users open that form the filter will still be there.


RunCommand


RunCommandlets you run certain menu commands. The syntax is:


DoCmd.RunCommand(Command)


Command is a required parameter and is an acCommand constant. Some of these are no
longer available in later versions of Access so it can be a matter of trial and error to find out
what still works. As an example, acCmdPrintSelection is still valid.


SetWarnings


TheSetWarningsmethod is used to suppress warning messages. For example, if you are
running a delete query, you would normally get a warning message that a number of records
will be deleted.
If you are running this as part of a VBA procedure, you do not want warning messages
pausing your code, and this is the way to turn them off. The syntax is:


Docmd.SetWarnings True


The WarningsOn argument is set to True to display the system messages, and False to
suppress them:


Docmd.SetWarnings False


Chapter 16: The DoCmd Object 217

Free download pdf