ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Editors / Report editor / Programming a report
  • Overview
  • Creating a report with parameters
  • Overview
  • Example
  • Printing a report with parameters
  • Example
  • Tip
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
When printing a report, you have the ability to pass parameters to this report. The report is called "Report with parameters".
For example, your report corresponds to a mailshot sent to all the customers. The text of the mailshot is entered in a control before running this report. This text corresponds to a parameter expected by the report.
Report with Parameters
Creating a report with parameters

Overview

The creation of a report with parameters is performed in several steps:
  1. Creating a report.
  2. Modifying this report to support the parameters:
    • Retrieving the parameters in the "Open" event of the report via the following syntax:
      PROCEDURE <ReportName>(<NameParam1>, ...
      <NameParam2>= "<DefaultValueParam2>", ...
      ...
      <NameParamN> = "<DefaultValueParamN>")

      Reminder: Some of the parameters passed to a procedure can be optional parameters. When declaring the procedure, the optional parameters must be described in last position (on the right), with a default value preceded by the "=" sign. For more details, see Procedure parameters.
    • Using these parameters in the report controls.
  3. Modifying (if necessary) the application in order to specify the different parameters.
  4. Printing the report while passing parameters. For more details, see Printing a report with parameters.

Example

The program required to create a report with parameters is illustrated by the following example:
  • "RPT_ParamReport" corresponds to a mailing sent to customers.
  • This report expects the text of the mailing entered in "EDT_MailingText" as parameter.
Implementation:
  1. Create the "RPT_ParamReport" report:
    • Click New in the quick access buttons.
    • The new element window appears: click "Report" then "Report".
    • The report creation wizard starts.
    • In the wizard, select "Mailshot" and validate.
      This report is linked to the "Customer" file of your analysis. For more details on how to create reports, see Reports.
  2. Customize this report.
  3. Write the following code in the "Open" event of "RPT_ParamReport":
    // Retrieve the parameter passed to the report and
    // pass a default parameter for the report test
    PROCEDURE RPT_ParamReport(sText = "Default value")
  4. In the Body block of this report, add the "STC_MailingText" static control used to display the text of the mailing.
  5. Write the following code in the "Before printing" of "STC_MailingText" event:
    // Retrieve the mailing text
    STC_MailingText = sText
  6. In an application window, add:
    • the "EDT_MailingText" edit control allowing the user to type the text of the mailing.
    • the "BTN_Print" button used to print the report.
Printing a report with parameters
To print a report with parameters, you must:
  1. Set the report print destination with iDestination (report viewer, print in an HTML file, etc.).
  2. Specify the following parameters with iPrintReport:
    • the name of the report to print.
    • the parameters.
Remarks:

Example

"RPT_ParamReport" corresponds to a mailing sent to customers. This report expects the text of the mailing entered in "EDT_MailingText" as parameter.
"RPT_ParamReport" is printed when "BTN_Print" is clicked on.
In this example, the click code of "BTN_Print" is as follows:
// Open report viewer
iDestination(iViewer)
// Print the report with parameters
iPrintReport(RPT_ParamReport, EDT_MailingText)
Tip
To run the test of a report with parameters from the report editor, a default value should be given to the parameters in the parameter declaration.
For example, to test the report from previous example, enter the following code in the "Opening" of the report "RPT_ParamReport" event:
// Retrieve the parameter passed to the report and
// pass a default parameter for the report test
PROCEDURE RPT_ParamReport(sText = "Default value")
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2023

Send a report | Local help