OpenReport Method

Applies To

DoCmd Object.

Description

The OpenReport method carries out the OpenReport action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

Syntax

DoCmd.OpenReport reportname [, view] [, filtername] [, wherecondition]

The OpenReport method uses the following arguments.

Argument

Description

reportname

A string expression that is the valid name of a report in the current database.

If you execute Visual Basic code containing the OpenReport method in a library database, Microsoft Access looks for the report with this name first in the library database, then in the current database.

view

One of the following intrinsic constants:

acNormal
acDesign
acPreview

acNormal prints the report immediately. If you leave this argument blank, the default (acNormal) is assumed.

filtername

A string expression that is the valid name of a query in the current database.

wherecondition

A string expression that is a valid SQL WHERE clause without the word WHERE.


Remarks

The maximum length of the wherecondition argument is 32,768 characters (unlike the Where Condition action argument in the Macro window, whose maximum length is 256 characters).

You can leave an optional argument blank in the middle of the syntax, but you must include the argument’s comma. If you leave one or more trailing arguments blank, don’t use a comma following the last argument you specify.

See Also

DoCmd Object, OpenReport Action, PrintOut Method.

Example

This example prints Sales Report using the existing query Report Filter.


DoCmd.OpenReport "Sales Report", acNormal, "Report Filter"