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 omit this argument, the current database (the value returned by the CurrentDb function) is used. If you specify a database other than the current database, that database must be open as a library database. |
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. |
Sub NormalReport()
Dim rpt As Report
Set rpt = CreateReport ' Create minimized report.
DoCmd.Restore ' Restore report.
End Sub
The next example creates a new form in the Northwind sample database based on the Customers form, and sets its RecordSource property to the Customers table. Run this code from the Northwind sample database.
Sub NewForm()
Dim frm As Form
' Create form based on Customers form.
Set frm = CreateForm( , "Customers")
DoCmd.Restore
' Set RecordSource property to Customers table.
frm.RecordSource = "Customers"
End Sub