CreateForm, CreateReport Methods

CreateForm, CreateReport Methods

See Also         Example

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

CreateForm([database[, formtemplate]])

CreateReport([database[, reporttemplate]])

The CreateForm and CreateReport methods have the following arguments.

Argument Description
database A string expression identifying the name of the database that contains the form or report template you want to use to create a form or 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.
formtemplate, reporttemplate A string expression identifying the name of the form or report you want to use as a template to create a new form or report. If you omit this argument, Microsoft Access bases the new form or 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 CreateForm and CreateReport methods when designing a wizard that creates a new form or report.

The CreateForm and CreateReport methods open a new, minimized form or report in form Design view or report Design view, respectively.

The form or report you specify for formtemplate or reporttemplate can be a form or report that you have created specifically to be used as a template, or any other form or report in the database identified by the database argument. Note that if the database specified by the database argument is not the current database, that database must be open as a library database. For more information on library databases, see Chapter 10, "The Windows API and Other Dynamic-Link Libraries," in the Microsoft Office 2000/Visual Basic Programmer's Guide. For information about how to obtain the Microsoft Office 2000/Visual Basic Programmer's Guide, click .

Note   If you have created a form or report template in another database that you would like to use as a template, you can simply import it into the current database, rather than loading a library database. Then check to make sure that the proper form or report name is listed in the Form Template or Report Template box on the Forms/Reports tab of the Options dialog box. Forms and reports subsequently created with the CreateForm or CreateReport method will be based on this template.

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

When you create a form or report with the CreateForm or CreateReport method, the form's or report's HasModule property is set to False (0). You can set this property to True (–1) if you want the new form or report to have a class module.

The CreateForm and CreateReport methods create minimized forms and reports.