Consultor Eletrônico



Kbase P84955: How to modify the selection criteria with the RecordSelectionFormula property in Crystal Reports Run
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   13/01/2009
Status: Verified

GOAL:

How to modify the selection criteria with the RecordSelectionFormula property in Crystal Reports 9 Runtime Engine with 4GL?

GOAL:

How to modify the selection criteria with the RecordSelectionFormula property in Crystal Reports 10 Runtime Engine with 4GL?

GOAL:

How to specify a modify the selection criteria of a Crystal Report?

GOAL:

How to programmatically add a custom WHERE clause to a Crystal Report?

FACT(s) (Environment):

Progress 8.3E
Progress 9.1D
Progress 9.1E
OpenEdge 10.x
Crystal Reports 9
Crystal Reports 10
Crystal Reports 11 (XI)
Windows

FIX:

Set the RecordSelectionFormula property of the Report object to modify the selection criteria or WHERE clause of a report. The following details the use of the RecordSelectionFormula property with a variety of data-types:

CHARACTER fields

For character fields, it is possible to specify a LIKE clause with wildcard characters.
? = one character
* = many characters

/* Samples */
chReport:RecordSelectionFormula = "~{order.salesrep} = 'DOS'".
chReport:RecordSelectionFormula = "~{order.salesrep} LIKE 'D??'".
chReport:RecordSelectionFormula = "~{order.salesrep} LIKE 'D*'".

DATE fields
For dates, the format YY/MM/DD or YYYY/MM/DD (- or / can be used as separators) must be used to ensure that the correct date range is used and encapsulate the dates with hash (#) marks.

/* Samples */
chReport:RecordSelectionFormula = "~{order.orderdate} = #97/12/31#".
chReport:RecordSelectionFormula = "(~{order.orderdate} >= #1997-12-01# AND ~{order.orderdate} <= #1997-12-31#)".

DECIMAL fields
Use dots to represent the decimal separator, ignoring regional settings of the PC

/* Sample */
chReport:RecordSelectionFormula = "~{customer.balance} <= 15.5".

INTEGER fields

/* Samples */
chReport:RecordSelectionFormula = "~{order.ordernum} = 1".
chReport:RecordSelectionFormula = "~{order.ordernum} >= 1 AND ~{order.ordernum} <= 10".