CreateReport Method

Microsoft Access Visual Basic

CreateReport Method

       

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.

expression.CreateReport(Database, ReportTemplate)

expression   Required. An expression that returns one of the objects in the Applies To list.

Database  Optional Variant. A string expression identifying 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. A string expression identifying the name of the report you want to use as a template to create a new report. If you omit this argument, Microsoft Access bases the new report on the template specified by the Forms/Reports tab of the Options dialog box, available by clicking Options on the Tools menu.

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.

The CreateReport method creates minimized forms and reports.

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.

Sub NormalReport()
    Dim rpt As Report

    Set rpt = CreateReport                ' Create minimized report.
    DoCmd.Restore                            ' Restore report.
End Sub