Get all the videos in this Access VBA collection 100% FREE by signing up at http://vbahowto.com/ms-access-tutorial
In this video I talk about the “With” Statement, and 2 DoCmd methods, DoCmd.OpenForm and DoCmd.OpenReport
There are many arguments for the OpenForm and OpenReport methods I will elaborate on at the blog, http://vbahowto.com
This is part 3 of a 3 part video series.1
Using the DoCmd Object:1
acViewPreview is a constant from the Access object library. I set the reports to open in this mode instead of just sending the report directly to the printer. This way you have a change to review the report before sending it to the printer to print.
To use the OpenForm method, use the following syntax:
DoCmd.OpenForm formname[, view][, filtername][, wherecondition][, datamode][, windowmode][, openargs]
The following table lists the arguments of the OpenForm Method.
|formname||the name of the form to open.|
The view inwhich a form opens. It can be one of the following constant: acDesign, acFormDS, acNormal (default), and acPreview. By default, the form opens in Form view.
*Interesting Note: Access constants have a two-letter prefix which identifies the object library where it’s defined. Constants from the Access library are prefixed with “ac”, and constants from the VBA Library are prefixed with “vb”
|filtername||The name of a query to use to restrict the records being returned.|
|wherecondition||A SQL WHERE clause, without the word WHERE, to use to restrict the records being returned.|
|datamode||The data mode in which a form opens. It can be one of the following constants: acFormAdd, acFormEdit, acFormPropertySettings (default), and acFormReadOnly|
|windowmode||The way in which a window opens. It can be one of the following constants: acDialog, acHidden, acIcon, and acWindowNormal (default). (Take a look at my video post MS Access VBA Control Events – PT3 for a sample of the acDialog option|
|openargs||The expression is used to set the form’s OpenArgs property, This setting is very versatile and is normally used by the receiving form’s Form_OnOpen Event procedure. Take a look at the previous point’s link for an example of it’s use.|