Creating a button to preview a report
Report criteria forms are typically used to preview and print reports from a report object source. To preview the report, you must have a Preview button on the report criteria form.
To create a Preview button for a report:
-
With the report criteria form open and in Design Mode, add a Button component
with these specifications:
- Name: PreviewButton
- Caption: sPreview
-
Create a form event and event handler to generate the report
preview:
- With the new Preview button selected, select the Events property sheet.
- In the Primary field, specify PreviewReport 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:
- Print Preview for a Report-template type form or an SSRS report definition file
- Run Form for a DataView report
- In the Response > Parameters field, click the ellipsis button.
- In the Event Handler Parms dialog box, for the Error Message, specify mPrintPreviewError.
- Click Type Specific Parameters.
-
If you are creating the report criteria form for:
- A Report-template type form or an SSRS report, continue with substep j.
- a DataView report, skip substep j. and continue with substep k.
-
In the Edit Background Task
Name and Parms dialog box, specify these values:
- Task Name: V(BGTaskName)
- Task Parms: V(BGTaskParms)
Continue with substep l.
-
In the Specify Form Run Options dialog box:
- Form: Select SBDataViewResults
- Click Set Variables
and use the Edit Set Variable Values dialog
box to set these variable values:
- DataViewName=nameOfDataView
where nameOfDataView is the name of the predefined DataView for which the report criteria form is being created.
- DataViewPromptForInputs=0
(This is optional, but if you do not set this variable value, and you submit the DataView report preview without any option specifications, you are prompted for the inputs when you click Preview.)
- InputParameter1=V(firstInputParameter)
where firstInputParameter is the name of the variable that corresponds with the first input parameter as set on the DataViews Setup form.
- InputParametern=V(nthInputParameter)
where n is the number of each succeeding input parameter and nthInputParameter is the name of the variable that corresponds with each succeeding input parameter as set on the DataViews Setup form.
- DataViewName=nameOfDataView
- In each dialog box, click OK until you have returned to the form.