Kbase P101144: How to override the Select Expert used in the Crystal Runtime Engine (RDC)
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  04/08/2005 |
|
Status: Unverified
GOAL:
How to override the Select Expert used in the Crystal Runtime Engine (RDC)
GOAL:
How can the list of fields available in the Crystal RDC Select Expert be extended?
FACT(s) (Environment):
Crystal Reports 9
Crystal Reports 10
Crystal Reports 11 (XI)
Windows
FIX:
In the Report Builder Runtime Engine, it is possible to set the RB-INCLUDE-RECORDS parameter to "?" to display a dialog box allowing the user to enter a filter expression.
The Crystal equivalents of this functionality are the RecordSelectionFormula method or the Select Expert called from the Crystal Reports Viewer Control. By default, the Select Expert will only contain fields that are displayed in the report. However, it is possible to re-populate the Select Expert with those fields that are contained in the database tables that were used to create the report.
This example assumes that the code sample detailed in solution P55350 is used as a starting point with the following changes:
- Variable declarations should be moved to the Definitions section
- Comment out the RELEASE OBJECT <handle> statements.
Steps to override the Select Expert:
1) Add the VSelExpert control to the window and set the Visible property to False
2) For the Crystal Reports Viewer Control, set the EnableSelectExpertButton to True in the control properties or programmatically
3) Select the Crystal Reports Viewer Control and open the AppBuilder's Section Editor
4) Set the Section to Triggers, select New, select the OCX.SelectionFormulaButtonClicked event from the list
5) Enter the following code after the parameter definition statements for the Event:
/* Sample Code Starts */
p-UseDefault = FALSE.
DEFINE VARIABLE chTable AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chField AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE VSelField AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE xx AS INTEGER NO-UNDO.
DEFINE VARIABLE yy AS INTEGER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER INIT 0 NO-UNDO.
DO yy = 1 TO chReport:DATABASE:tables:COUNT :
chTable = chReport:DATABASE:tables:ITEM(yy).
DO xx = 1 TO chTable:FIELDS:COUNT:
chField = chTable:FIELDS:ITEM(xx).
chCtrlFrame-2:VSelExpert:AddField().
VSelField = chCtrlFrame-2:VSelExpert:GetField(iCount).
VSelField:FieldType = chField:ValueType.
VSelField:FieldName = SUBSTRING(chField:NAME,2, LENGTH(chField:NAME) - 2).
VSelField:AddValue(chField:NAME).
iCount = iCount + 1.
RELEASE OBJECT chField.
END.
RELEASE OBJECT chTable.
END.
chCtrlFrame-2:VSelExpert:Show().
p-selctionFormula = chCtrlFrame-2:VSelExpert:GetSelectionString(FALSE).
/* Sample Code Ends */
6) Run the code and choose the Select Export button to display the Select Expert dialog. Choose New to display the field listing.