Application.CreateReport Method

Access Developer Reference

The CreateReport method creates a report and returns a Report object. For example, suppose you are building a custom wizard to create a sales report. You can use the CreateReport method in your wizard to create a new report based on a specified report template.

Syntax

expression.CreateReport(Database, ReportTemplate)

expression   A variable that represents an Application object.

Parameters

Name Required/Optional Data Type Description
Database Optional Variant The name of the database that contains the report template you want to use to create a report. If you want the current database, omit this argument. If you want to use an open library database, specify the library database with this argument.
ReportTemplate Optional Variant The name of the report you want to use as a template to create a new report.

Return Value
Report

Remarks

You can use the CreateReport method when designing a wizard that creates a new report.

The CreateReport method open a new, minimized report in report Design view.

If the name you use for the reporttemplate argument isn't valid, Visual Basic uses the report template specified by the Report Template setting on the Forms/Reports tab of the Options dialog box.

Example

The following example creates a report in the current database by using the template specified by the Report Template setting on the Forms/Reports tab of the Options dialog box.

Visual Basic for Applications
  Sub NormalReport()
    Dim rpt As Report
Set rpt = <strong class="bterm">CreateReport</strong>                ' Create minimized report.
DoCmd.Restore                            ' Restore report.

End Sub

See Also