
- •Seagate Crystal Web Reports Server Overview
- •What is the Web Reports Server?
- •Who should use the Web Reports Server?
- •Web Reports Server Features
- •New Features in Version 7
- •The Web Reports Server vs. Active Server Pages
- •Sample Web Sites
- •Implementing the Web Reports Server
- •Choosing a Web Reports Server
- •System Requirements
- •Installing the Web Reports Server
- •Confirming Correct Installation
- •Virtual Directories
- •Creating a Web Site
- •For More Information
- •Crystal Web Reports Server Administration
- •The Web Reports Server Configuration Application
- •Page Server Tab
- •Image Server Tab
- •Report Exporting Tab
- •Server Mappings Tab
- •Report Viewing Tab
- •The Page Server and the Image Server
- •Smart Navigation
- •Drilling Down on Data
- •Database Location
- •Web Reports Server Commands
- •The Crystal Web Reports Server Command Expert
- •Constructing Report Requests
- •Changing Selection Formulas in Web Reports
- •SQL and ODBC Data Sources
- •SQL Stored Procedures and Parameter Fields
- •Report Exporting
- •Refreshing Web Report Data
- •Web Reports Server Architecture
- •The Web Reports Server Extension
- •The Seagate Crystal Web Image Server
- •The Seagate Crystal Web Page Server
- •Report Processing
- •Job Manager Overview
- •Seagate Crystal Report Engine Automation Server
- •Visual InterDev Design-time ActiveX Control
- •Using an Existing Report
- •Building a Report at Runtime
- •Editing Active Server Pages
- •Customizing the Crystal Smart Viewer
- •Modifying the Report
- •Session Timeout
- •Sample Web Site
- •Crystal Smart Viewer Overview
- •Features of the Crystal Smart Viewers
- •Printing from the Crystal Smart Viewers
- •Using Crystal Smart Viewers in Applications
- •Crystal Smart Viewer for HTML
- •Limitations of HTML Reports
- •Crystal Smart Viewer for Java
- •Adding the Viewer to a Web Page
- •Crystal Smart Viewer for ActiveX
- •AuthentiCode Certification
- •Adding the Viewer to a Web Page
- •Downloading the Viewer from the Server
- •ActiveX Viewer Example
- •Introduction to the Crystal Report Engine
- •Before using the Crystal Report Engine in your application
- •Using the Crystal Report Engine
- •Crystal Report Engine API
- •Declarations for the Crystal Report Engine API (REAPI)
- •Using the Crystal Report Engine API
- •The Print-Only Link
- •The Custom-Print Link
- •Working with Parameter Values and Ranges
- •Working with section codes
- •Crystal Report Engine API variable length strings
- •Crystal Report Engine API structures
- •Working with subreports
- •Changing report formats
- •Exporting reports
- •PEExportTo Overview
- •PEExportOptions Structure
- •Considerations when using the export functions
- •Handling Preview Window Events
- •Distributing Crystal Report Engine Applications
- •Additional Sources of Information
- •Using the Crystal Report Engine API in Visual Basic
- •When to Open/Close the Crystal Report Engine
- •Embedded Quotes in Visual Basic Calls to the Crystal Report Engine
- •Passing Dates/Date Ranges in Visual Basic using the Crystal Report Engine API Calls
- •Identifying String Issues in Visual Basic Links to the Crystal Report Engine
- •Hard-coded Nulls in Visual Basic User Defined Types
- •Visual Basic Wrapper DLL
- •Crystal ActiveX Controls
- •Adding the ActiveX Control to your Project
- •Using the ActiveX Controls
- •Upgrading from the Crystal Custom Control
- •Crystal Report Engine Automation Server
- •Adding the Automation Server to your Visual Basic Project
- •Using the Automation Server in Visual Basic
- •Object Name Conflicts
- •Viewing the Crystal Report Engine Object Library
- •Handling Preview Window Events
- •Distributing the Automation Server with Visual Basic Applications
- •Sample Applications
- •Active Data Driver
- •Data Definition Files
- •Using the Active Data Driver
- •Creating Data Definition Files
- •Using ActiveX Data Sources at Design Time
- •Crystal Data Object
- •CDO vs. the Crystal Data Source Type Library
- •Using the Crystal Data Object
- •Crystal Data Object Model
- •Crystal Data Source Type Library
- •Creating a new project and class
- •Adding the type library
- •Implementing the functions
- •Passing the CRDataSource object to the Active Data Driver
- •Crystal Data Source Projects
- •Grid Controls and the Crystal Report Engine
- •Bound Report Driver and Bound Report Files
- •Crystal ActiveX Control Properties
- •Creating a Bound Report using the Crystal ActiveX Control
- •Creating a Formatted Bound Report
- •Creating a Formatted Bound Report at Runtime
- •Sample Application
- •ActiveX designers
- •The Report Designer Component vs. Seagate Crystal Reports
- •Data Access
- •No drag and drop between reports – use copy and paste
- •Conditional Formatting
- •Preview Window
- •Pictures
- •Guidelines
- •Subreports
- •The dual formula environment
- •Application Distribution
- •Installing the Report Designer Component
- •System Requirements
- •Installation
- •Using the Seagate Crystal Report Designer Component
- •Adding the Report Designer Component to a Project
- •Selecting Data
- •The Report Expert
- •Adding the Smart Viewer
- •Running the Application
- •CrystalReport1 - The Report Designer Component
- •CRViewer1 - The Smart Viewer Control
- •The Code
- •Report Packages
- •Working with data
- •ADO and OLEDB
- •Connecting to data with ADO
- •Connecting to data with RDO
- •Connecting to data with DAO
- •Data Environments
- •Data Definition Files
- •Report Templates
- •ODBC, SQL, and PC data sources
- •Report Designer Overview
- •Introduction to the Report Designer Component
- •Report Designer Architecture
- •Report Designer Object Model Programming
- •Report Designer Object Model Introduction
- •Obtaining a Report object
- •Displaying the report in the Smart Viewer
- •Setting a new data source for the report
- •Using ReadRecords
- •Passing fields in the correct order
- •Working with secure data in reports
- •Handling the Format event
- •Changing the contents of a Text object
- •Changing OLE object images
- •Working with Sections
- •Working with the ReportObjects collection
- •Working with the FieldObject object
- •Working with the SubreportObject object
- •Working with the Database and DatabaseTables objects
- •Working with the CrossTabObject object
- •Exporting a report
- •The Application object
- •Report events
- •Microsoft Access Sessions
- •Programmatic ID
- •Report Distribution Considerations
- •Distributing reports as part of the application
- •Saving reports as external files
- •Saving data with reports
- •VCL Component Overview
- •Installation
- •Delphi 2
- •Delphi 3 & 4
- •C++ Builder 3
- •Programming Overview
- •Introduction to the Object Inspector
- •Changing Properties in the Object Inspector
- •Changing Properties at Runtime
- •Delphi Programmers introduction to the SCR Print Engine
- •Dealing with SubClass Objects
- •Consistent Code
- •Using the Retrieve method
- •Working with subreports
- •Other Guidelines
- •Programming Tips
- •Always Set ReportName First
- •Discard Saved Data
- •Verify Database
- •Connecting to SQL Servers
- •Changing Tables & Formulas
- •Changing Groups & Summary fields
- •Using the Send methods
- •Using the JobNumber property
- •TCrpeString
- •Introduction
- •TCrpeString VCL Properties
- •Using the TCrpeString
- •Using Variables with Formulas
- •Introduction
- •Examples
- •About Section Names
- •Introduction
- •Methodology
- •StrToSectionCode
- •C++ Builder 3
- •Introduction
- •Code Syntax
- •Additional Code Examples
- •Known Problems
- •Retrieving ParamFields from a Subreport
- •DialogParent and Temporary Forms
- •Technical Support

Using Variables with Formulas
The following topics are discussed in this section.
Introduction, Page 215
Examples, Page 216
Introduction
Delphi variables can be used with Crystal Reports Formulas and the Crystal Component's Formulas object if they are declared as string or converted to string (regardless of the actual data type) before being passed to the Report. The value of the variable passed to the Report must be in the same format and look exactly as if entered directly into the Crystal Reports Formula Editor:
●String data types must be surrounded by double quotes: "This is a String". Single quotes are also valid within Crystal Reports but because Delphi uses single quotes, all string data types passed to Crystal should use double quotes to avoid conflicts.
●Numbers do not need quotes: 1234
●Dates must be put in the Crystal Reports Date function format: Date(YYYY,MM,DD)
The VCL Formulas object can only be used to change formulas that already exist in Crystal Reports, not to create new formulas. The Formulas object can contain numerous Formula items, which can either be created by using the Retrieve method:
Crpe1.Formulas.Retrieve;
or the manual Add method:
Crpe1.Formulas.Add('FormulaOne');
NOTE: Although Crystal Reports automatically prefixes the @ symbol to each Formula Name when a Formula is created, the @ must not be included when using the Name or Add methods of the Formulas object in Delphi.
Once the Formulas object has items in it, the next step is to navigate to the desired item. This can be done in 3 different ways:
1.Use the default Item array property (subscript):
Crpe1.Formulas[0];
2.Use the Name lookup property:
Crpe1.Formulas.Name := 'FormulaOne';
3.Use the ItemIndex property:
Crpe1.Formulas.ItemIndex := 0;
Seagate Crystal Visual Component Library |
215 |

Once the desired Formula has been located, the Formula property can be set. This is a stringlist that contains the actual Formula text. Since it is a stringlist, three different methods can be used to write to it:
1.The default Strings array (subscript):
{Clear the Formula first} Crpe1.Formulas.Formula.Clear; Crpe1.Formulas.Formula[0] := '"Formula String"';
NOTE: It is also acceptable, and perhaps easier to read, if the subscript specifying the Formulas item is also used in the expression, although since the VCL objects have an internal Index, it is not strictly necessary:
{Clear the Formula first} Crpe1.Formulas[0].Formula.Clear; Crpe1.Formulas[0].Formula[0] := '"Formula String"';
If the subscript value is not known, it can be obtained right after setting the Formula Name:
{Clear the Formula first} Crpe1.Formulas.Name := 'FormulaOne'; i := Crpe1.Formulas.ItemIndex;
Crpe1.Formulas[i].Formula.Clear;Crpe1.Formulas[i].Formula[0] := '"Formula String"';
2.The Text property:
Crpe1.Formulas.Formula.Text := '23';
3.The Assign method
Crpe1.Formulas.Formula.Assign('Date(1998,01,01)');
Examples
The following examples are presented in this section.
Passing a variable from Delphi that results in a String data type in Crystal Reports, Page 216 Passing a variable from Delphi that results in a Numeric data type in Crystal Reports, Page 218 Passing a variable from Delphi that results in a Date data type in Crystal Reports, Page 219
Passing a variable from Delphi that results in a String data type in Crystal Reports
As both Delphi and Crystal Reports require string values to be surrounded by quotes, a variable that results in a string data type in Crystal Reports requires two sets of quotes: one set for Delphi and one set for Crystal Reports. The first two examples show how to pass the variable when the value of the variable is hard-coded. The third example shows how to pass the variable when the value of the variable is entered via an EditBox at runtime.
Seagate Crystal Visual Component Library |
216 |
Example 1: The value is hard-coded and includes the extra quotes while assigning the variable a value:
var
sTmp: string; {Declare sTmp as a string variable} begin
{Assign a value to the variable. Note the use of two sets of quotes} sTmp := '"This is a string"';
Crpe1.Formulas.Name := 'StringFormula';
{Set the variable to the VCL Formula property}
Crpe1.Formulas.Formula.Text := sTmp;
{Display the value that is passed to the Report}
ShowMessage(Crpe1.Formulas.Formula.Text);
{The Message Box will display: "This is a string"} {The Report will print: This is a string}
Example 2: The value is hard-coded and includes the extra quotes in the Formula statement:
var
sTmp: string; {Declare sTmp as a string variable} begin
{Assign a value to the variable. Note the use of one set of quotes} sTmp := 'This is a string';
Crpe1.Formulas.Name := 'StringFormula';
{Concatenate Formula with: opening quote, variable name, closing quote} Crpe1.Formulas.Formula.Text := '"' + sTmp + '"';
{Display the value that is passed to the Report} ShowMessage(Crpe1.Formulas.Formula.Text);
{The Message Box will display: "This is a string"} {The Report will print: This is a string}
Example 3: Shows how to pass a variable when the value is entered via an EditBox at runtime:
var
sTmp: string; {Declare sTmp as a string variable} begin
{Assign the contents of an EditBox to the sTmp variable} sTmp := Edit1.Text;
Crpe1.Formulas.Name := 'StringFormula';
{Concatenate Formula with: open quote, variable name, close quote}
Crpe1.Formulas.Formula.Text := '"' + sTmp + '"'; {Display the value passed to the Report} ShowMessage(Crpe1.Formulas.Formula.Text);
{The Message Box will display: EditBox value with surrounding double quotes} {The Report will print: EditBox value without surrounding double quotes}
Seagate Crystal Visual Component Library |
217 |
Passing a variable from Delphi that results in a Numeric data type in Crystal Reports
Because the Formulas object passes only string data types, variables declared as type Integer must be converted to a string before being passed to Crystal Reports. The first example shows a number in a variable declared as type String. The second example shows a variable declared as type Integer converted to a string by using an additional string variable and the Str() function.
Example 1: The value is hard-coded and the variable declared as type String:
var
sNum: string; {Declare sNum as a string variable} begin
{Assign a value to the variable. Note the use of one set of quotes} sNum := '1234';
Crpe1.Formulas.Name := 'NumberFormula';
{Pass the variable value to the Formula text} Crpe1.Formulas.Formula.Text := sNum;
{Display the value passed to the Report} ShowMessage(Crpe1.Formulas.Formula.Text); {The Message Box will display: 1234} {The Report will print: 1234}
Example 2: The value is hard-coded and the variable declared as type Integer:
var
nTmp: integer; {Declare nTmp as an integer variable} sNum: string; {Declare sNum as string variable}
begin
{Assign a value to the integer variable.} nTmp := 1234;
{Assign the value of nTmp to the sNum string variable} Str(sNum, nTmp;
Crpe1.Formulas.Name := 'NumberFormula';
{Pass the variable value to the Formula text}
Crpe1.Formulas.Formula.Text := sNum;
{Display the value passed to the Report}
ShowMessage(Crpe1.Formulas.Formula.Text); {The Message Box will display: 1234} {The Report will print: 1234}
Seagate Crystal Visual Component Library |
218 |
Passing a variable from Delphi that results in a Date data type in Crystal Reports
Crystal Reports accepts dates only as a string data type in the Date(yyyy,mm,dd) format. The first example shows the date hard-coded and assigned to a single variable as a numeric string. The second example shows the date hard-coded and assigned to three variables as numeric strings. The third example shows how to pass the variable when the date is entered via three EditBoxes at runtime.
Example 1: The date is hard-coded and assigned to a single variable as a string. Formatting is done in the Formula statement:
var
sDate: string; {Declare sDate as a string variable} begin
{Assign a value to the variable. Note that the year is 4 digits, the month and day are 2 digits. The year, month and day are in the order Crystal Reports expects and are delimited by commas, and the entire string is surrounded by quotes.}
sDate := '1995,01,31'; Crpe1.Formulas.Name := 'DateFormula';
{Concatenate Formula with: the word Date, opening parenthesis, the variable name, closing parenthesis}
Crpe1.Formulas.Formula.Text := 'Date(' + sDate + ')'; {Display the value passed to the Report} ShowMessage(Crpe1.Formulas.Formula.Text);
{The Message Box will display: Date(1995,01,31)} {The Report will print: 95/1/31}
{The Date format will be Windows default unless formatted otherwise in the Report}
Example 2: The date is hard-coded and assigned to three variables as numeric strings. Formatting is done in the Formula statement:
var
{Declare sYear, sMonth, sDay as string variables} sYear, sMonth, sDay: string;
begin
{Assign a value to sYear; Note that the year is 4 digits}
sYear := '1995';
{Assign a value to sMonth; Note that the month is 2 digits} sMonth := '01';
{Assign a value to sDay; Note that the day is 2 digits} sDay := '31';
Crpe1.Formulas.Name := 'DateFormula';
{Concatenate the Formula with: the word Date, opening parenthesis, the sYear variable, a comma, the sMonth variable, a comma, the sDay variable,
a comma, and a closing parenthesis}
Seagate Crystal Visual Component Library |
219 |
Crpe1.Formulas.Formula.Text := 'Date(' + sYear + ',' + sMonth + ',' + sDay + ')';
{Display the value passed to the Report} ShowMessage(Crpe1.Formulas.Formula.Text);
{The Message Box will display: Date(1995,01,31)} {The Report will print: 95/1/31}
{The Date format will be Windows default unless formatted otherwise in the report}
Example 3: The date is entered via three EditBoxes at runtime. The formatting is included while assigning the variable its value:
var
{Declare sYear, sMonth, sDay, and sWholeDate as string variables} sYear, sMonth, sDay, sWholeDate: string;
begin
{Assign the Year Entry EditBox value to sYear} sYear := Edit1.Text;
{Assign the Month Entry EditBox value to sMonth} sMonth := Edit2.Text;
{Assign the Day Entry EditBox value to sDay} sDay := Edit3.Text;
{Concatenate Formula with: the word Date, an opening parenthesis, the sYear variable, a comma, the sMonth variable, a comma, the sDay variable, a
comma, and a closing parenthesis, and assign the value to the sWholeDate variable}
sWholeDate := 'Date(' + sYear + ',' + sMonth + ',' + sDay + ')'; Crpe1.Formulas.Name := 'DateFormula';
{Pass the variable value to the Formula text} Crpe1.Formulas.Formula.Text := sWholeDate; {Display the value passed to the Report} ShowMessage(Crpe1.Formulas.Formula.Text);
{The Message Box will display: Date(YYYY,MM,DD) where YYYYMMDD represents whatever was entered in the Year Entry, Month Entry, and Day Entry Edit Boxes at runtime}
{The Report will print: YYYY/MM/DD}
{The Date format will be Windows default unless formatted otherwise in the Report}
Seagate Crystal Visual Component Library |
220 |