Kbase P80533: How to change the selection criteria of a Crystal report?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  6/21/2004 |
|
Status: Unverified
GOAL:
How to change the selection criteria of a Crystal report?
GOAL:
How to change the selection criteria of report called by the Crystal Reports 9 Runtime Engine with 4GL?
GOAL:
How to control record selection in a report with the Crystal Reports 9 runtime engine and 4GL?
GOAL:
How to change the selection criteria (normally controlled by the Select Expert) of a Crystal report with 4GL?
FACT(s) (Environment):
Progress 8.3E
FACT(s) (Environment):
Progress 9.1D
FACT(s) (Environment):
Crystal Reports 9
FIX:
This sample was tested with Crystal Reports 9. The report was created against the Sports2000 database and simply displays the contents of the Customer table. To control which records are selected in the report, the RecordSelectionFormula property must be set. This will override the criteria set by the Select Expert.
The following example uses a hard-coded selection formula but this can be constructed dynamically.
1) Insert the Crystal Report Viewer Control into a window.
2) Add a button and copy the following code into the CHOOSE trigger.
DEFINE VARIABLE chApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chReport AS COM-HANDLE NO-UNDO.
CREATE 'CrystalRuntime.Application' chApplication.
CREATE 'CrystalRuntime.Report' chReport.
/* Enter details of your ODBC connection here */
chApplication:LogOnServer("crdb_odbc.dll", "<DSN_Name>", "", "<Username>", "pub").
/* Insert full path to the Crystal report */
chReport = chApplication:OpenReport("<Path_To_Report>").
/* Sets Record Selection Formula - note use of curly brackets around the field-names and the tilde (~) used */
chReport:RecordSelectionFormula = STRING("~{customer.custnum} >= 1 AND ~{customer.custnum} <= 10").
/* Enables the CRViewer's Navigation Controls */
chCtrlFrame:CRViewer9:EnableNavigationControls = TRUE.
/* Enables the CRViewer's Group Tree */
chCtrlFrame:CRViewer9:DisplayGroupTree = FALSE.
/* Enables the CRViewer's Export button */
chCtrlFrame:CRViewer9:EnableExportButton = TRUE.
/* Disables the CRViewer's Search control */
chCtrlFrame:CRViewer9:EnableSearchControl = FALSE.
/* Set the report source */
chCtrlFrame:CRViewer9:ReportSource = chReport.
/* View the report */
chCtrlFrame:CRViewer9:ViewReport().
RELEASE OBJECT chApplication.
RELEASE OBJECT chReport.