Access Openform Macro

P: n/a
Hi,
Simple version of the question...
How do I use the where clause of the open form command to show an
account with a matching ID to be displayed when the form is opened?
Eg. I select a record on a continuous form and click and edit button.
The button runs the open form code. I want the APPID of the current
record on the continous form to match the APPID of the record viewed
on the new form to be opened.
Complex version of the question;
I have a form - FRMAPPOINTMENTS with entries stored in a table,
TBLAPPOINTMENTS. I have a query based on this table QRYAPPOINTMENTS,
and a continuous form based on this query - FRMQUERYAPPOINTMENTS.
(There is some (probably flawed!) logic behind this bizarre setup).
I want to select a record in the continous form FRMQUERYAPPOINTMENTS
and by clicking on an edit button on this form to open the form
FRMAPPOINTMENTS at the corresponding record. The matching fields are
the APPID in both forms.
I have tried numerous where clauses in the openform command and having
no luck.
Thanks,
  1. Access Macro Open Form Filter
  2. Access Openform Macro Excel
  3. Access Macro Openform With Filter
-->

The Form Name box in the Action Arguments section of the Macro Builder pane shows all forms in the current database. This is a required argument. If you run a macro containing the OpenForm action in a library database, Microsoft Access first looks for the form with this name in the library database, and then in the current database. Microsoft Access Help Database Forums and Wiki by UtterAccess.com. Docmd.openform With Date In Where Condition, Access 2010 Options. Apr 21 2013, 11. 7 rows  Sep 18, 2015  OpenForm macro action.; 6 minutes to read; In this article. A powerful way to change from the design-time default behaviour is using the DocDmd.OpenForm arguments. OpenForm with FormName. The simple way to open a form is by supplying the FormName and keeping all the defaults. DoCmd.OpenForm FormName:='Customer' When opened this way Access interprets the command with defaults as here.

The OpenForm method carries out the OpenForm action in Visual Basic.

Syntax

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

expression A variable that represents a DoCmd object.

Parameters

NameRequired/OptionalData typeDescription
FormNameRequiredVariantA string expression that's the valid name of a form in the current database. If you execute Visual Basic code containing the OpenForm method in a library database, Access looks for the form with this name first in the library database, and then in the current database.
ViewOptionalAcFormViewAn AcFormView constant that specifies the view in which the form will open. The default value is acNormal.
FilterNameOptionalVariantA string expression that's the valid name of a query in the current database.
WhereConditionOptionalVariantA string expression that's a valid SQL WHERE clause without the word WHERE.
DataModeOptionalAcFormOpenDataModeAn AcFormOpenDataMode constant that specifies the data entry mode for the form. This applies only to forms opened in Form view or Datasheet view. The default value is acFormPropertySettings.
WindowModeOptionalAcWindowModeAn AcWindowMode constant that specifies the window mode in which the form opens. The default value is acWindowNormal.
OpenArgsOptionalVariantA string expression. This expression is used to set the form's OpenArgs property. This setting can then be used by code in a form module, such as the Open event procedure. The OpenArgs property can also be referred to in macros and expressions.
For example, suppose that the form that you open is a continuous-form list of clients. If you want the focus to move to a specific client record when the form opens, you can specify the client name with the OpenArgs argument, and then use the FindRecord method to move the focus to the record for the client with the specified name.

Remarks

You can use the OpenForm method to open a form in Form view, form Design view, Print Preview, or Datasheet view. You can select data entry and window modes for the form and restrict the records that the form displays.

The maximum length of the WhereCondition argument is 32,768 characters (unlike the WhereCondition action argument in the Macro window, whose maximum length is 256 characters). Logitech camera drivers windows 10.

Access Macro Open Form Filter

Example

The following example opens the Employees form in Form view and displays only records with King in the LastName field. The displayed records can be edited, and new records can be added.


The following example opens the frmMainEmployees form in Form view and displays only records that apply to the department chosen in the cboDept combo box. The displayed records can be edited, and new records can be added.


The following example shows how to use the WhereCondition argument of the OpenForm method to filter the records displayed on a form as it is opened.

Access Openform Macro Excel

Support and feedback

Access Macro Openform With Filter

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.