OpenReport


Opens a report.

Syntax

DoCmd.OpenReport ReportName[, View][, FilterName][, WhereCondition][,   WindowMode][, OpenArgs]

with the following parameters:

ReportName

A String containing the name of the report in the current database.

View

One of the following members of the AcView enumeration: acViewDesign, acViewNormal (prints the report immediately, the default), and acViewPreview.

FilterName

The name of a query in the current database upon which the report will be based.

WhereCondition

A string containing a SQL WHERE clause without the WHERE keyword.

WindowMode

One of the following AcWindowMode constants defining the state of the open window: acDialog (sets the report’s Modal and Popup properties to Yes), acHidden (the report is not visible), acIcon (the report is minimized), and acWindowNormal (the default; the report is opened based on its property settings).

OpenArgs

A value to be assigned to the report’s OpenArgs property. Typically, this is used to take some action in the report’s Load or Open event procedure.

Example

Public Sub PrintCustomerRpt() Dim strReportName As String strReportName = "rptCustomerList" DoCmd.OpenReport strReportName, acViewPreview, , "txtState = 'NJ'" DoCmd.PrintOut acPages, 1, 2 End Sub

Comments

  • Once you’ve opened the report in preview mode, you can print a selected number of its pages by calling the DoCmd.PrintOut method. This is illustrated in the example.

  • You can retrieve the names of all reports in the database programmatically by iterating the AllReports collection. It is available by retrieving the value of the AllReports property of the Application.CurrentProject object.




Access VBA Programming
Microsoft Access VBA Programming for the Absolute Beginner
ISBN: 1598633937
EAN: 2147483647
Year: 2006
Pages: 214
Authors: Michael Vine

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net