Language:


Adding Check Boxes to the Specification Window - Exclusive Search Controlled by Check Boxes

Exclusive searches start from the point where all records in a particular register will be listed in a report, and records are removed from the report if they meet the criteria controlled by the check boxes. In this section, we will illustrate an exclusive search in a Customer list report by adding a check box that will exclude companies with fax numbers. Follow these steps:
  1. Create a new report. On the 'Data' card, specify that the Customer register is to be the primary register. On the 'Layout' card, design the output of the report as required.

  2. Go to the 'Input' card, and click the [Check Box] button above the report display area. The 'Check Box' dialogue box opens:

    Label
    Enter the name of the check box, as it will appear in the specification window. The Label should indicate the purpose of the check box to the person producing the report.

    Variable Name
    Enter a name for the boolean variable that is controlled by the check box. Include at least one alpha character in the name and do not use spaces or punctuation marks of any kind. Use the underscore _ instead of a space. Ideally, the variable name should reflect the purpose of the variable.

    This variable will be set to 1 if the person producing the report checks the box in the specification window. Otherwise, it will be set to 0.

    Default Checked
    Use this option if you want the value of the variable to be set to 1 by default. The check box will be checked when the specification window opens. If you do not use this option, the value of the variable to be set to 0 by default and the check box will not be checked when the specification window opens.

    Width
    This field is not used in check boxes.

    h, v
    Use these two fields to specify where you want the check box to be placed in the specification window. Enter co-ordinates (in pixels) for the top left-hand corner of the check box (not the label): h (horizontal) is the distance from the left-hand edge of the specification window, while v (vertical) is the distance from the top edge. Defaults are offered: they assume the standard Hansa vertical spacing of 20 pixels between check boxes.

  3. Click the [OK] button. The check box is placed in the report display area. This shows what the specification window will look like:

    Placing the check box in the specification window in this way has the effect of declaring the variable, so there is no need to do this on the 'Data' card as well.
  1. At the moment the check box exists only in the specification window. Now you need to specify what should happen when it is checked by the user. In this example, if the person producing the report checks the box, there should be a search for Customers with no Fax Number, thus effectively removing those with Fax Numbers from the report. If they do not check the box, then there should be no search and Customers with and without Fax Numbers should be shown in the report.

    Change to the 'Data' card. Click on the line in the report display area marked "Register: Customers..." to specify that the search is to be carried out in the Customer register, and then click the [Selection] button.

  2. Enter a formula in the 'Selection' dialogue box as shown below:

    The formula is:
    cExclFax == 0 or blank(vrCustomer.Fax)
    This states that if the check box (cExclFax) is not checked, nothing will happen. Otherwise (i.e. if the check box is checked) there will be a search for Customers with no Fax Number. In the expression vrCustomer.Fax, "Fax" is the internal name for the Fax Number field in the Customer register.

    blank is a function inside Hansa that you can use to find records where a specified string field is empty. You can also use string_fieldname == "" (e.g. vrCustomer.Fax == ""). Use !blank (or string_fieldname > "") to find records where a specified field contains a value (i.e. any value). In the case of decimal and integer fields, empty and zero are not necessarily the same. num_fieldname == 0 will find records where a specified decimal or integer field is empty or contains the value 0. blank(num_fieldname) will only find records where the decimal or integer field is empty, not those where it contains the value 0.

  3. Click the [OK] button to add the Selection to the Customer register section of the report display area:

  1. When the report is produced without using the new option, it will list all records in the Customer register. When the report is produced using the new option, it will only list records in the Customer register that do not have fax numbers.

    A possible improvement to the Skip Customers With Fax No. check box might be to offer options to print Customers with Fax Numbers only, Customers without Fax Numbers only, and Customers with and without Fax Numbers. This would be accomplished more efficiently using radio buttons and is described here.

Adding a Second Check Box
Extra check boxes can be added to the report, but they should also initiate exclusive searches (searches that remove records from the initial selection). In this example, we will add a check box that will exclude companies with email addresses from the report.
  1. On the 'Input' card, add a new check box to the specification window of the report, as described in step 2 above.

  2. On the 'Data' card, add a new selection to the Customer register section, as described in steps 4-6 above.

    "eMail" is the internal name for the Email Address field in the Customer register.

    The result will be two "Selection:" lines in the report display area. The order of these two lines is not important.

    When there is more than one "Selection:" line in the report display area, they are treated as having the logical operator "and". There will be a search for records that meet the first condition and that meet the second condition. Another way to do this is to join the two "Selection:" lines together:
    (cExclFax == 0 or blank(vrCustomer.Fax)) and (cExclEmail == 0 or blank(vrCustomer.eMail))
    Note that each check box condition is enclosed in its own set of brackets. The two parts of a single exclusive check box condition are joined by "or", while several check box conditions are joined together using "and". This makes sure that there will be a search for records that meet condition one and that meet condition two.

    The specification window will now contain two options that you can use in the following ways:

    Neither option checked
    The report will list all records in the Customer register.

    One option checked
    The report will list records without fax numbers or records without email addresses, depending on the option chosen.

    Both options checked
    The report will only list records without fax numbers and without email addresses.
For details about the syntax that you should use when entering a formula in the 'Selection' dialogue box, please refer to the Syntax page.