Creating a button to print a report
Report criteria forms are typically used to preview and print reports from a report object source. To generate (print) the report, you must have a Print button on the report criteria form.
To create a Print button for a report:
-
With the report criteria form open and in Design Mode, add a Button component
with these specifications:
- Name: PrintButton
- Caption: sPrint
-
Create a form event and event handlers to generate the report:
- With the new Print button selected, select the Events property sheet.
- In the Primary field, specify GenerateReport as the form event name.
- Click the ellipsis (…) button for the Primary field.
- In the Event Handlers dialog box, click New.
- In the Event Handler Properties dialog box, specify a Response > Type of Run Background Task.
- In the Response > Parameters field, click the ellipsis button.
- Click Type Specific Parameters.
-
In the Edit Background Task
Name and Parms dialog box, specify these values:
- Task Name: V(BGTaskName)
- Task Parms: V(BGTaskParms)
-
If you are planning to schedule the report for automatic generation
later, specify these additional values:
- Task Status: V(BGTaskStatus)
- Task Number: BGTaskNumber
- In each dialog box, click OK until you have returned to the Event Handlers dialog box.
-
Repeat substeps 2d. through 2i. to create a second event handler with these
specifications:
- Response > Type: Run Script
- Response > Parameters: ReportSubmitted()
Note: This event simply runs a built-in script that lets you know when the report has been successfully generated. To have the system notify you when the report is not successfully generated, specify an error message in the Error Message field of the Event Handler Parms dialog box. - In the Event Handlers dialog box, click OK.
- Save and close the report criteria form.
-
Reopen the form and test it to make sure the report prints.
Note: At this point, the entire contents of the report source should print, because typically you have not yet set up the associations between this form and the report object.