DoCmd.SetParameter

Set a parameter before opening a Form, Report or macro (Access 2010+).

Syntax
      DoCmd.SetParameter(Name, Expression)

Key
   Name       The name of the parameter.
              The name must match the name of the parameter
              expected by the BrowseTo, OpenForm, OpenQuery,
              OpenReport, or RunDataMacro method.

   Expression An expression that evaluates to a value to
              assign to the parameter.

Calls the SetParameter method once for each parameter you need.

Each call to SetParameter will add or update a single parameter in an internal parameters collection. The parameters collection is passed to the BrowseTo, OpenForm, OpenQuery, OpenReport, or RunDataMacro method. When the method is run the parameters collection supplies the needed parameters. When the method is finished the parameters collection is cleared.

To be sure the parameters have not been cleared (by some other form/procedure), your calls to SetParameter should immediately precede BrowseTo, OpenForm, OpenQuery, OpenReport, or RunDataMacro.

Example

Private Sub cmdOpenOrder_Click()
DoCmd.SetParameter "prmOrderID", Me!txtOrderId
DoCmd.OpenForm "frmOrders"
End Sub

“The aim of science is not to open the door to infinite wisdom but to set a limit to infinite error” ~ Bertolt Brecht (Life of Galileo)

Related:

OpenForm - Open a form.


© Copyright SS64.com 1999-2013
Some rights reserved