Language:

HansaManuals

Creating a Report Using the Report Generator
Creating a Report Generator Report - Specifying the Primary Register
Creating a Report Generator Report - The Appearance of the Report
Creating a Report Generator Report - Choosing a Print Destination
Creating a Report Generator Report - The Width of the Report Window
Creating a Report Generator Report - Printing the Report
Creating a Report Generator Report - Adding White Space
Creating a Report Generator Report - Adding Searches
Creating a Report Generator Report - Adding a Secondary Register
Creating a Report Generator Report - Using Variables and Formulae
Creating a Report Generator Report - Printing Information from Matrices
Creating a Report Generator Report - Bringing Information in from Other Registers
Creating a Report Generator Report - Page Breaks
Creating a Report Generator Report - Filtering Records (Print If)
Creating a Report Generator Report - Adding Check Boxes to the Specification Window
Creating a Report Generator Report - Adding Radio Buttons to the Specification Window
   - Searches Controlled by Radio Buttons
   - Sorts Controlled by Radio Buttons
Creating a Report Generator Report - Searching for Records within a Period
Creating a Report Generator Report - Break Points, Subtotals and Totals
Creating a Report Generator Report - Blocks
Creating a Report Generator Report - Syntax
Creating a Report Generator Report - Useful Functions
Example Reports - Listing Sales Figures
Creating a Report Generator Report - Common Error Messages

Tutorials for Standard Accounts

Creating a Report Generator Report - Adding Radio Buttons to the Specification Window - Sorts Controlled by Radio Buttons

This page describes using radio buttons to control the sort order in a Report Generator report.

---

When you declare a primary (or other) register in a Report Generator report, you should use the Sort By field in the 'Register' dialogue box to specify the order in which its records will be listed in the report (as described on the Specifying the Primary Register page). The Sort By field allows you to sort by a single field, or to use one of the pre-defined indexes. This means that the person designing the report has control over the sort order, not the person printing the report. If you want to give this control to the person printing the report (i.e. you want to offer various sort order options) you can do so using radio buttons and variables.

As described here, a group of radio buttons sets the value of an integer variable. You can in turn use this integer variable to set the value of a string variable, which will be the name of the sort order option chosen by the user. You should then enter the name of the string variable in the Sort By field in the 'Register' dialogue box. This will ensure the records will be listed in the report in the correct order. Follow these steps:

  1. Create a new report in the Report Generator module and go to the 'Input' card. Use the [Radio Button] button above the report display area to add radio button options for the different sort orders that you want to be available.

    In this example, four options will be offered:

  2. The next step is to declare the string variable that will contain the sort order option chosen by the user. Return to the 'Data' card, click the [Variable] button above the report display area and complete the 'Variable' dialogue box as shown below:

  3. Now you need to set the value of the string variable depending on the radio button chosen by the user. You should do this on the 'Data' card using the [Code] button. You should add one line of code for each radio button option.

    This is the first one:

    The code is:

    if (rSort == 0) then begin vsSort = "Code"; end;

    This code first tests for the value of the radio button variable rSort. If the value is 0 (zero), then the value "Code" is assigned to the string variable vsSort. As vsSort is a string variable, you must enclose "Code" in inverted commas. "Code" is the name of a sort order option, in this case specifying that Contacts will be sorted into Contact Number order. vsSort can contain any valid sort order for the register in question: to obtain a list and to ensure the correct spelling and case usage, open the 'Register' dialogue box and open the 'Paste Special' list from the Sort By field. Be sure not to confuse == and =.

    Note the syntax that you must use in the if statement:

    if (condition) then begin consequent action; end;

    The condition must be placed in brackets and followed by the phrase "then begin". The consequent action must be followed by a semi-colon (;), the word "end" and a second semi-colon.

    The four lines of code should appear in the report display area as follows:

  4. Click the [Register] button above the report display area to declare the primary register. Enter the name of the string variable in the Sort By field:

    When you click [OK], the register will be added to the report display area in the normal way:

    It can be seen that the radio buttons determine the value of the integer variable rSort. This variable in turn sets the value of the string variable vsSort, which you will then use in the 'Register' dialogue box to determine the sort order.

    Note that the four "Code:" lines must appear above the declaration of the register. The "Code:" lines set the value of the string variable: the string variable must already contain the value when it is used in the register declaration. So, if you declared the primary register before adding the "Code:" lines, be sure not to click on the "Register: Contacts..." line before clicking the [Code] button.

  1. Design the output of the report as required on the 'Layout' card.
Please follow the links below for more details about:
---

Go back to: