The VBA code is the feature in Ms Access for programming to adding more function to Access database, using Visual Basic. To open the VBA window, press the Alt + F11 buttons in your keyboard. The Open Form function is to open specific form when an action is occurred, such as when clicking button in a form. Even through the feature can be achieved with command button wizard, sometimes you may need to use it in VBA for more complex or specified result.
The general syntax for Open Form function:
DoCmd. OpenForm (FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)
FormName: the string contains name of the form. It is the only required parameter, the rest of the parameter below is optional.
View: determine how the form will be opened and presented. Values: acNormal (normal form), and acFormDS (datasheet).
FilterName: string that refers to the query name in the database
WhereCondition: it is same like SQL Where function. It is to extract specific result from the database.
DataMode: about how the data entry mode for the form. There are 3 values: acFormAdd (opens the form on a ‘new’ (empty) form, acFormEdit (allows editing), and acFormReadOnly (no editing allowed).
WindowMode: determine how the window mode in which the form opens, like pop up or not. The value are: acWindowNormal (Normal view), acDialog (dialog box), and PopUp.
OpenArgs: the function to pass data to the form. The OpenArgs function can be used for several things, such as creating Modules, or procedure before opening the form. Sometimes, the OpenArgs is become the function instead the parameter for OpenForm, even though it still need to be used with OpenForm.
1. DoCmd. OpenForm (“MemberDetails”, acNormal, , , acFormEdit, PopUp)
This will open the MemberDetails form in Normal Mode, that can be edited and is a PopUp form.
2. DoCmd.OpenForm “BooksDetails”, , , , “FirstName = ’Danang’”
This will open the BooksDetails form, with condition only for Danang.
3. Example in Library Database
It will open the BookForm form, with CategoryID is BR. Read more tutorial for Microsoft Access VBA.
Related Access Database
- ms access vba open form to specific record
- open vba code in access
- vba function in access
Access Database Tags: #ms access vba check to see if form is open #ms access vba on form open #ms access vba open form on new record #ms access vba open form on startup #ms access vba open form openargs #ms access vba open form popup #ms access vba open form read only #ms access vba open form specific record #ms access vba open form with parameters #ms access vba openform parameters #ms access vba refresh all open forms