Access VBA Macro Programming

(Joao Candeias) #1

screen resolutions, and what looks good on your development screen can look terrible on a
user’s screen. Using this when a form or report is opened gets around this problem.
The syntax is:


DoCmd.Maximize


It has no parameters. Note that if you are not from North America, “Maximize” is spelled
with a z, not an s. It is an easy mistake to make, leaving you wondering why you get an error
when it runs!
There is also aMinimizemethod, which works in the same way, but minimizes the active
window.


OpenForm


TheOpenFormmethod will open a form. It is very useful when you have a hierarchy of
forms that the user navigates through. The syntax is:


DoCmd.OpenForm _
(FormName,View,FilterName,WhereCondition,DataMode,WindowMode,OpenArgs)


The FormName is a required parameter, but the others are optional:

 View An acFormView constant that specifies the view that the form will open in.
This is acNormal by default.
 FilterName The name of a query in the current database.
 WhereCondition An SQL WHERE clause without the word WHERE.
 DataMode An acFormOpenDataMode constant that specifies the data entry mode for
the form.
 WindowMode An acWindowMode constant that specifies the window that the form
opens in.
 OpenArgs This sets the form’sOpenArgsproperty.

OpenQuery


TheOpenQuerymethod will open a query so that the user can scroll through the results.
However, it is better to open a form (based on a query) as a datasheet so that the user has all
the filtering functionality. The syntax is:


DoCmd.OpenQuery(QueryName,View,DataMode)


The QueryName is a required parameter, but the others are optional.

 View An acFormView constant that specifies the view that the form will open in.
This is acNormal by default.
 DataMode An acFormOpenDataMode constant that specifies the data entry mode for
the form.

Chapter 16: The DoCmd Object 215

Free download pdf