Skip to content

OnConstrain - Report

Used to setup the conditions for filtering the records from the main table in the report

Type: Event

Syntax

Procedure OnConstrain

Description

This event can be used to setup the conditions for filtering the records from the main table in the report if the report does not use a DataDictionary object (DDO) for finding the records. When an object based on a (sub)class of Report (for example BasicReport or cWinReport2) sets the Server property, the find operations use the DDO and bypass the OnConstrain in the Report based object. If the object does not set the server property and it does set the Main_File property, the OnConstrain is used.

Sample

This code tells the report to do its own record find operations in the Customer table and filters the records on State equals to CA(lifornia)

Object oReport is a cWinReport2
    Set Report_Title to "Customer List"

    Set Main_File to Customer.File_Number
    Set Ordering to 1

    Procedure OnConstrain
        Constrain Customer.State Eq "CA"
    End_Procedure

Sample

This code tells the report to use the Customer_DD object for record find operations. Since the Customer_DD is supposed to use the customer table, the records of the customer table are found. If that DDO uses an OnConstrain procedure, records will be filtered by those conditions. The OnConstrain in the oReport object will not be used.

Object oReport is a cWinReport2
    Set Report_Title to "Customer List"

    Set Server to Customer_DD
    Set Ordering to 1

    Procedure OnConstrain
        Constrain Customer.State Eq "CA"
    End_Procedure