Copyright: Copyright 1998, Seagate Software


Crystal Reports Component : Title

Unit

UCrpe32

Description

The 32-bit Delphi VCL component for Seagate Crystal Reports 7, 6 and 5.x.x.108.

Delphi 5 Version: 7.5.0.51

Delphi 4 Version: 7.4.0.51

Delphi 3 Version: 7.3.0.51

Delphi 2 Version: 7.2.0.51

C++ Builder 4 Version: 7.4.0.51

C++ Builder 3 Version: 7.3.0.51

C++ Builder 1 Version: 7.1.0.51

What's New?	Programming Introduction

Installation	Programming Tips

Technical Support	Frequent Questions

C++ Builder Users: Read This!	Distributing an Application

Properties

Methods

Events

Properties by Group

Methods by Group

Utility Methods (UCrpeUtl)

Types

Constants

Known Problems


What's New?

See also

The Seagate Crystal Reports VCL Component has now been largely re-designed since it's various versions from Crystal 4.5 to 6.0.  This version takes full advantage of the VCL's object-oriented capabilities to provide the most flexible Delphi interface to the Crystal Reports runtime engine (CRPE32.DLL) offered yet.  This re-designed component is not available in a 16-bit version due to the restrictions of the 16-bit environment.  However, the 16-bit VCL may be updated periodically to add some of the new functionality.  Monitor the website for updates.

Changes to the 7.x.0.51 Version

This update was released for two reasons:

1. Delphi 5 compatibility.  Delphi 5 insists that the DsgnIntf unit, which contains Delphi's property editor classes, not be included in the USES clause of any unit which will be compiled with a Runtime package.  This necessitated some code-shuffling within the Crystal VCL code units.  Consequently, the UCrpeReg unit now contains all the code that used to be included in UCrpeDlg.  To make a runtime package, add the UCrpe32.pas unit and leave out the UCrpeReg unit.  To make a design-time package, choose the UCrpeReg unit.

2. Printer.SetCurrent.  This new method was added to the Printer object.  It's purpose is to allow the Delphi environment to be updated with the printer specified in the VCL, so that if a Print Dialog is opened, it will have that Printer selected by default.  As well, the internal DevMode structure was removed as it caused some other problems with newer Printer drivers.

3. To fix some minor problems reported with the last release.  These are listed below and have all been fixed in this release:

ParamFields

Retrieving non-string values was not working correctly.  Numeric parameters were not showing in the Crystal Prompt dialog (when ShowDialog was set to True). The ParamFields.AsDate property was causing an error because the internal DateToStr method was renamed to CrDateToStr (to avoid a conflict with Delphi's DateToStr method), and then we missed renaming this occurence of the function.  These errors have all been fixed.  Also, the internal float conversion for Numeric and Currency Paramfields should now handle the Windows International Decimal Symbol correctly.

PrintOptions.Send

Was causing an Access Violation when PromptForOptions was True.  This bug was introduced in the last update when the Print Engine declarations were extracted into a separate source file.

PrintWindow, ReportWindowHandle, etc.

Any method that retrieved the Crystal Preview Window handle could cause an Access Violation if the retrieved window handle was too large to fit into a Small Integer.  This has been fixed by making the return value a HWnd variable.

SectionHeight

The height of a section cannot be less than the value originally set when the Report was designed.  The VCL was comparing it's Section Height value with the current Report setting, and only passing in the value if it was greater than the current value.  However, the current value might not be the original value if the Report was run two or more times in a row.  Therefore, since there was no way to determine the original Section Height of a Report if it had been run numerous times with different settings on the same Print Job, the comparison was removed, and the VCL will now send any changed Section Height value into the Report.  If this value happens to be less than the Report's original designed value, a Print Engine error will occur.

Crystal 5 and ParamFields

There was a small error in the PEConvertVInfoToPFInfo method (CRDynamic.pas), and in the CrStrToDate method (UCrpeUtl.pas) which affected Crystal 5 users (thanks to Steve McKinlay for the tips).

LogOnInfo.Send

This was not working properly in some cases, because the Password property had an accidental subscript included in the source code (hence only one letter of the Password string was being checked, instead of the whole string).

Tables.Send

There was an obscure bug in the code which could cause problems if the Tables were not all retrieved, but Propagate was set to True.

Changes to the 7.x.0.50 Version

This update consists of new features exposed by the Seagate Crystal Reports 7 - Maintenance Release, as well as bug fixes and other code enhancements.

Graphs: New Classes and Properties

•	Two new Graph classes were added: GraphAxis and GraphOptionInfo.

•	GraphType has been enhanced with the addition of many more GraphType Styles.

•	GraphText now allows for Font changes to all of the text properties.

GroupCondition / GroupOptions: Time and DateTime support

GroupCondition and GroupOptions now support grouping on Time and DateTime fields.

ParamFields: PickList and Null values

•	The ParamFields class supports passing multiple default values to a Report so the user will be prompted with a selectable drop-down list of values to choose from.  This feature has been further enhanced with the PickList property, which allows a descriptive label to be given which will show either in the place of, or along with, the actual parameter default value choices.

•	Passing of Null values is now supported.  Use the CrEmptyStr or CrwNull constant.

•	A fix was implemented in the Paramfields.Send method so that the VCL will now try to locate the actual Parameter specified if the Main Report and a Subreport have Parameter fields with the same names.

Printer: GetDevMode/SetDevMode and other Improvements

•	Occasionally we received complaints that Access Violations were being experienced in the Printer routines on certain machines.  This was very hard to reproduce, but we have simplified the Printer code in this update to alleviate the problem.  To this end, we implemented an internal DevMode structure, so that the Printer.PMode pointer will usually be pointing to an address that is allocated by the VCL itself.  If the PMode property is assigned a new address, it copies the DevMode structure values from that new address into the VCL DevMode structure, and then points to the VCL again.

•	Two methods were added to the Printer class: GetDevMode and SetDevMode.  These functions allow exporting and importing DevMode values to/from the internal VCL devmode structure.

•	OnPrinterSend now passes the DevMode pointer out as a parameter.  This allows the developer to over-ride the VCL's default behaviour and pass a DevMode pointer to the Report that is external to the VCL.

•	Internal change: when GetPrinterInfoFromName fails, it now exits instead of raising an error in Printer.Send.

•	Internal change: the GetPrinter method was renamed to GetCrpePrinter to avoid an error in C++ Builder (the compiler was confusing our internal GetPrinter method with Printer.GetPrinter).

ReportOptions: AsyncQuery property & Subreport support

•	A new property, AsyncQuery, has been added.  This is analogous to the property in Report Options of Crystal Reports Designer: Perform Query Asynchronously.

•	ReportOptions now applies to Subreports as well as the main Report.

Subreports: More Flexible Syntax

The Subreports class has been restructured and improved internally, so that it now supports the following type of syntax:

    Crpe1.Subreports[1].Selection.Formula.Text := '{company.STATE} = "CA"';

Previously, this sort of expression used to require two lines of code: one to set the Subreports Item and another to set the Selection.  Now these can be combined into one line.  All the properties supported by Subreports are available to be used in this way.  Also, a Clear method was added to Subreport items: Subreports[2].Clear.  This would clear just the properties associated with the second Subreport.

Tables: SubName, CheckDifferences, Test, and IndexOfName

•	A SubName property has been added to the Tables class, which allows for changing the table name on databases like Access, where the Tables are contained inside a Database and merely setting the Name property only affects the Database, not the Table within it.  Now you can point to a different Table as well.

•	The CheckDifferences method has been added to the Tables class.  This method analyzes the structure of the table information the Report was saved with and compares it with the table that is currently specified in the VCL.  A series of descriptive messages are returned if there are any differences, in which case, VerifyDatabase should be called to fix up the Report.

•	The Test method was also added to the Tables class, and simply checks to see if the specified table exists and if a connection can be made to it.

•	The IndexOfName method looks up a Table by it's name and returns the VCL index number of that table.

WindowButtonBar: Toolbar Tips and Document Tips

Two new properties were added to the WindowButtonBar class.

•	The ToolbarTips property controls the display of hints over the Preview Window button bar.

•	The DocumentTips property controls the display of hints over fields in the Preview Window Report area.

Miscellaneous Property and Method changes

•	A new property,  SQLTablesOnly was added to the LogOnInfo class, so that the developer can now choose between retrieving all the Tables, or just the SQL Tables.

•	A CrpePath property was added for setting path that CRPE32.DLL will be loaded from, if possible.  If CRPE32.DLL cannot be loaded, a Windows Error message is now appended onto the normal VCL error.

•	The wOnRightMouseClick was changed to wOnMouseClick, as left and middle clicks are now also supported.

•	A Test method was added to SessionInfo.

•	The OnError Event now accepts three types of responses in its return parameter, which is of type TCrBoolean: cTrue(Ignore), cFalse(Silent Abort), cDefault(use the Internal Error Handler).

•	An OnCreate Event was added to allow users to override the initial default settings of TCrpe properties.

•	SectionFormatFormulas and AreaFormatFormulas now have separate properties for each FormulaName instead of the previous Name/Formula combination.  This should make them easier to use.

Previous code would have looked like this:

  Crpe1.SectionFormatFormulas.Section := 'RHa';

  Crpe1.SectionFormatFormulas.Name := 'sfSuppress';

  Crpe1.SectionFormatFormulas.Formula.Text := 'True';

New code would look like this:

  Crpe1.SectionFormatFormulas.Section := 'RHa';

  Crpe1.SectionFormatFormulas.Suppress.Text := 'True';

More Efficient Code Organization

The source code for the VCL has been re-organized in the following ways:

•	All the Print Engine declarations for CRPE32.DLL have been moved to a new dynamic header file: CRDYNAMIC.PAS.  This header can also be used stand-alone to do direct API calls to CRPE32.DLL, and supports automatic structure size setting, and version-checking.

•	A new registration unit has been added: UCRPEREG.PAS.  This makes for easier registration, and separates the registration functions so that they are not included with a runtime package.

•	A new include file was created: UCRPEDEF.INC.  This contains the conditional defines and compiler settings used throughout the VCL.

•	Utility functions were separated into the UCRPEUTL.PAS file.  Some of these utility functions were renamed to avoid conflicts with SysUtils (DateToStr to CrDateToStr, etc.).

•	Any classes that could contain multiple items were further broken down into a pseudo collection class structure, with a main class and an item class.  This makes the code much more readable and somewhat more compact.

Miscellaneous Enhancements

•	Changed all Add methods from procedures to functions that return the index number of the added item.

•	Changed all CopyFrom methods from functions to procedures as the return value was superfluous.

•	Added a new CrwNull constant.  This constant has the same value as CrEmptyStr.

•	Extra code was added to make sure the following calls go to the main Report only: Printer, PrintOptions, SummaryInfo, PrintDate.

•	Changed the VCL palette icon for TCrpe and created new icon for the yet-to-be-released TCrpeLog component.

•	Changed the AboutBox credits easter egg.

Support for Delphi 5

The Source Code and Sample Application have been tested and updated to support Delphi 5.  At the time of this release, the only version of Delphi 5 available was a beta, so we can't guarantee that this will work with the final release.  However, we will have an official update for Delphi 5 available shortly after it is released.

Bug Fixes

•	Fixed Margins.Send so that all margins are tested for changes.  Previously, the check would stop as soon as one change was detected, resulting in usually only the first Margin property being sent.

•	Fixed a small error in PrintOptions.Send that prevented OutputFileName from being sent.

•	Fixed LogOnInfo.Test so that the Table number is used instead of the index number.

•	Fixed the Tables.Retrieve and Tables.Send methods so that PESetTablePrivateInfo doesn't get called with Crystal Reports 5.x.x.108.

•	Wherever the CrEmptyStr constant can be passed, non case-sensitive checks are now made.

•	Added improved Error checking to the internal GetErrorMsg routine so that "Error 140: Undefined Print Engine Error" should almost never happen.  The routine now also tries to get the error using the current Report Job Number as well as zero (which is sometimes required to get the proper error from LogOnServer).

•	The clNoColor constant was removed -- use clNone instead.

•	The Error Message strings were improved with more information about where the Error occured.

•	The SectionAsCode methods for the Graph calls were fixed so that they no longer behave as look-up properties, but can be set.

•	GraphOptions.Min and GraphOptions.Max now default to -1 instead of 0, as the GraphOptions.Send routine would ignore these values if they were zero, assuming it as default.

•	Connect.Retrieve, LogOnInfo.Retrieve, Tables.Retrieve, and a few other classes have been improved so that they no longer reset some of the global properties of those classes.  For example, Connect.Propagate is no longer reset when Connect.Retrieve is called.  If you want these properties reset, call the Clear method or assign the property a default value in code.

•	The WindowParent property had been enhanced to support MDI Parent forms.  However, the Caption on the internally created MDI Child form was not picking up the WindowStyle.Title property value.  This has been fixed.

•	A small fix was implemented in the Crpe1.Execute method so that VerifyDatabase is not called unless SCR7+ is being used.

•	Color constant handling was improved in the SectionFormat.BackgroundColor and GraphText Font color properties by adding an internal function: RGBToColor, and using the SysUtils' ColorToRGB method.  These two methods are now used to make color translation between COLORREF and TColor more accurate.

•	Removed PrintDate from being a Subreport-supported class as it is not supported by them in the CRW Designer.  PrintDate only applies to the main Report.

Sample Application: Changes

•	Fixed the FormClose of the Sample App's parent window so that it will not blow up if the Form is closed when the Report is generating.  Also added code so the button bar buttons are inactive until the Preview Window is drawn.

•	Eliminated Spin controls from the VCL Object Inspector edit dialogs and the Sample Application.  This was to make distribution to C++Builder a bit easier.

•	More Sample applications are now included with the VCL: TabControl, MemTest, RptPassword, GetPrinter.

Changes to the 7.x.0.25 Version

Released a few days after the "20" version, this update consists of some small fixes to the source code.  All references to StrPCopy were replaced with StrCopy or PChar typecasting, all references StrPas() were replaced with String(), all strings with array subscripts (ie. string[20]) were replaced with regular strings.  These changes fixed a small error with passing stringlists that crept into the "20" version (SQL Query, Selection Formula, etc. were getting truncated at 255 characters).

Changes to the 7.x.0.20 Version

This is the second update to the VCL since it was shipped with Crystal Reports 7.  A few new things were added, and some small but important fixes were implemented, as listed below:

Active Data Object / Crystal Data Object Support

Crystal Data Object/Active Data Object support were added to the Tables class.  This was done via the addition of a DataPointer property, which accepts the address of a CDO/ADO/RDO/DAO Rowset.  The Crystal Data Object (CDO) opens up some interesting possibilities, since it can take any data that is written to it's memory arrays, such as from a ListBox, or Grid, and display it on a Report.  It can also be used to eliminate another connection to a database or server, since the data is passed directly from the application into the Report.  See the Help topics for the Tables class for more information.

Clearing Formulas in the Report

Formulas, Selection, GroupSelection, AreaFormatFormulas, and SectionFormatFormulas can all now be passed the CrEmptyStr constant which will cause the formula in the Report to be cleared.  Example:

  {When the Report is run, the first formula

   will be cleared in the Report}

  Crpe1.Formulas[0].Formula.Text := CrEmptyStr;

DiscardData Method

Added a DiscardData method which immediately discards the Saved Data from a Report.  This is faster than setting the DiscardSavedData property, which only acts at Crpe1.Execute.  Also, it can be used to discard data after a Report is run once and before it is run the again, so that retrieving values, such as ParamFields, will not reflect the values that were passed in the first time the Report was run.  Example:

{The old way: data is only discarded when Execute is called}

Crpe1.DiscardSavedData := True;

{The retrieved Parameters reflect the saved data in the Report}

Crpe1.ParamFields.Retrieve;

{The new way: data is discarded immediately}

Crpe1.DiscardData;

{The retrieved Parameters do not reflect saved data}

Crpe1.ParamFields.Retrieve;

Printer.GetCurrent: New Parameter

An extra parameter was added to the Printer.GetCurrent method (bAfterPrintDlg).  This parameter is to be set according to whether the GetCurrent method is called after showing a Delphi PrintDialog.  This affects DevMode handling, so that the VCL's Printer.PMode should now reflect changes made in the Properties dialog called from the PrintDialog.

ParamField Changes

Some changes and fixes were made to the ParamFields class.  These are:

1. Retrieving ValueMin and ValueMax were not working for String Parameters.  This has been fixed.

2. Improved the Date, DateTime, and Time comparison in ParamFields.Send, so that Dates such as "01,01,1997" and "1,1,1997" will not be recognized as different values when determining which ParamFields have changed.

3. Improved the Value/CurrentValues/DefaultValues interaction.  The new functionality in CurrentValues was causing all sorts of grief, so we implemented a few changes to make this more intuitive.

a. The DefaultValues and CurrentValues are no longer retrieved automatically when ParamFields.Retrieve is called.  Instead, a new method, RetrieveValues must be called for each Parameter Field for which you wish to obtain the Default and Current Values.

b. When the ParamFields are sent to the Report (on Execute), DefaultValues and CurrentValues are not processed if they have no items contained in them (ie. CurrentValues.Count = 0).

c. To clear all the DefaultValues or CurrentValues from a Report that is loaded in the VCL, pass the CrEmptyStr constant to the property, ie.  Crpe1.ParamFields[0].CurrentValues.Text := CrEmptyStr;  Naturally, the DefaultValues and CurrentValues properties can still be cleared in the VCL as before, ie. Crpe1.ParamFields[0].CurrentValues.Clear; (they are descended from TStringList, and can be treated in the same way).  This will not clear the values from the Report though.

PrintOptions Changes

The Help file documentation stated that passing 0 to PrintOptions StartPage and StopPage would cause "All Pages" to be selected.  This was not working as advertised, but has now been fixed.

CharSepQuote and CharSepSeparator changed

Two properties in the Export class have been slightly modified.  CharSepQuote was changed from "string[1]" to "char" type, and CharSepSeparator was changed from "string[16]" to "string".

PromptForLogOn and LogOnInfo.Send

A slight change was made to the way LogOnInfo.Send works in relation to the PromptForLogOn property.  If LogOnInfo did not send any information to the Report (because the Report did not have any SQL tables, or the VCL did not have any items in the LogOnInfo object), and PromptForLogOn was set to True, the Execute method would exit before completion.  This was fixed by making the LogOnInfo.Send return a TCrBoolean (3 possible results) instead of a Boolean.  See the Help file on LogOnInfo - Send for more details.

UCDIALOG Renamed

The UCDIALOG.PAS source file and compiled unit was conflicting with another product on the market that had a unit with the same name.  Therefore, we renamed it to UCRPEDLG.PAS.

Typed @ Operator

The VCL source code was modified to allow the Compiler Option "Typed @ Operator" to be on or off.  Formerly, errors would be generated when recompiling the source with this option on.

Loading CRPE32.DLL at startup

Some code was added to the TCrpe.Loaded event to prevent loading of the CRPE32.DLL when Delphi initially starts up with a project that uses the Crystal Reports component.

Resource leaks fixed

Some small resource leaks caused by not freeing PrintOptions, PrintDate, Margins, Connect, and SessionInfo, were fixed. Some small resource leaks caused by unsafe use of the TStringList's GetText method were fixed.

Stack overflow problem fixed

The internal GetErrorMsg method was improved to avoid a stack overflow if the CRPE32.DLL could not load.

Compiler directives

Compiler directives were added in the source code to make it easier to compile the same source file in Delphi 2,3, or 4, or C++ Builder 1 or 3, with minimal to no changes necessary.

Changes to the 7.x.0.10 Version

This was the first update to the VCL that was shipped with the Crystal Reports 7.  The following items were fixed:

Subreports

Only one Subreport could be retrieved.  Fixed.

ParamFields

Setting ParamFields so that the Prompt dialog would not show did not always work due to a conflict between the Value and DefaultValues/CurrentValues properties.  Fixed.

MDI Capability in WindowParent

Using the built-in MDI capability of WindowParent caused an  Access Violation due to not closing the Crystal window before closing the MDI Child.  Fixed.

Help File completed

The Help file was completed.

ConnectMethod

A ConnectMethod property was added to distinguish which of the two classes (Connect or LogOnInfo) should be used when a Report is run.

PromptForLogOn

A PromptForLogOn property was added to the LogOnInfo class.  See the Help file for details.

Improvements to the Sample Application

The Sample Application was improved with Drag and Drop capability, better Page Tab handling, a new Retrieve Options dialog, etc.

NEW Seagate Crystal Reports 7.0 features

The features added for the 7.0 release are as follows:

Design-time Dialogs

Over 50 new Dialogs have been added to the VCL to enhance the Design-Time capability.  Each sub-class can now be edited in a visual manner, allowing for quick testing and learning of the VCL's features.

ReportOptions class

All of the items available in the SCR Designer's Report Options dialog can now be set via the VCL's ReportOptions class.

SQL Expressions class

A new type of Formula is available in SCR 7.  It is called an SQL Expression, and is similar to regular formulas, except that the formula language is in SQL syntax, and the processing of these expressions will be done on the Server.  These are supported in the VCL via an additional Expressions sub-class underneath the SQL sub-class.

Verify Database

A new method was added: VerifyDatabase.  This is the same as the Database | Verify Database menu item in SCR Designer, and will cause Crystal to re-read the database structure before running the Report.

Field Mapping

An often-requested enhancement is now here!  Field names can now be mapped to new ones when changing the location, name or structure of the database that the Report was originally designed against.  In the past, the fields would simply be removed from the Report if the field names did not match.  Now they can be mapped to new field names and the Report will be updated accordingly.  To accomplish this, a new property has been added: FieldMapping.  If this is set to fmPrompt a built-in dialog will appear when the VerifyDatabase method is called.  If FieldMapping is set to fmEvent then an OnFieldMapping event will be triggered when the VerifyDatabase method is called, allowing the developer to handle the mapping themselves.

Right Mouse Click Event

There is a new Preview Window callback event for the right mouse-click, which sends back all sorts of information about the area or field that was clicked on: wOnRightMouseClick.

Enhanced ParamFields

ParamFields have been greatly enhanced to include such options as:

•	Stored Procedure Parameters now handled through the ParamFields object;

•	Parameters from Crystal SQL Designer (formerly Query Designer) handled through the ParamFields object;

•	Addition of DateTime and Time Parameters;

•	Parameters can accept a Range of values, or even an array of Ranges (see Ranges);

•	Drop-down list of DefaultValues to choose from;

•	Grouping of Parameters (with or without mutual exclusiveness) (see Info);

•	Allowing or disallowing of null values in Stored Procedure Parameters (see Info);

•	Allowing or disallowing editing of the prompting values (see Info);

•	Setting upper and lower limits to the values that can be entered (see ValueMin/ValueMax);

•	Setting an EditMask for the values that can be entered.

Print To File via PrintOptions

Printing to File is now possible via the OutputFileName property of the PrintOptions class.

New Export Options

•	Exporting to Excel5 has been improved with the addition of a new subclass, Excel, under the Export class.

•	Exporting to an Application is now possible with the addition of a new Export.Destination type: toApplication. The Application name can be specified, or the exported file can be run with the associated application via Windows' file extension associations.

•	ReportDefinition was added as an Export.FileType.  This exports a text file outlining the details of a Report.

Other VCL-specific features

•	A ConnectMethod property has been added to allow the VCL to distinguish whether to use Connect or LogOnInfo to set the Table log on information for SQL tables or ODBC datasources.  Any old projects that are recompiled with the new VCL, and that use the LogOnInfo class, will need the following line added to the code:  Crpe1.ConnectMethod := useLogOnInfo;

•	A PromptForLogOn property was added to the LogOnInfo class.  If this property is set to true, it will cause the VCL (upon Execute or LogOnInfo.Send) to provide a dialog showing all the unique connections required in the Report, along with the LogOn parameters required.  A Password can then be entered (the other LogOn properties can be modified as well), and the Report will attempt to run with the provided connection information.

•	An IndexOf method has been added to sub-classes such as Formulas, SectionFormat, etc., that use a string type for the key property (ie. Formula Name).

•	A CopyFrom method has been added to most of the sub-classes to allow easy copying of values from one sub-class to a temporary structure.  This is similar to Delphi's Assign method.

•	WindowState, WindowStyle.Title, and the WindowSize properties are now "active" properties, which means they can be used to change the status of an open Preview Window.

•	A Send method was added to WindowSize so that it can now actively change the size of an open Preview Window.

•	A RetrieveWindowState method was added to the TCrpe class so that it can now retrieve the Window state of an open Preview Window.

•	Two new events have been added: OnPrinterSend and OnGetVersion.

OnPrinterSend - takes place just before the Printer settings are passed from the VCL to the Print Engine.  This allows the developer to slip in some last minute changes to the DevMode structure, over-riding any VCL Printer property settings.

OnGetVersion - takes place when the FileVersion of the CRPE32.DLL is being checked, just before the Print Engine is opened.  This allows the developer to over-ride the version number obtained from the CRPE32.DLL.

•	WindowStyle.ControlBox was renamed to SystemMenu, which is more in harmony with standard Windows naming convention.

•	A Disabled property was added to the WindowStyle class, allowing the Crystal Preview Window to be enabled or disabled.  This is an active property that will also work on the currently open Preview Window, and thus can be set after the Execute method.

•	ShowWindow, HideWindow and RetrieveWindowState methods have been added.

•	SectionMinHeight was renamed to SectionHeight.

•	MDI capability was added added to WindowParent property.  If WindowParent is set to a Form that has a FormStyle of fsMDIForm, a Delphi MDI-child window will be created by the VCL, and the Crystal Preview Window will be attached to this child form.

Changes from Crystal Reports 4.5, 5.0, and 6.0 VCL's

The major changes from previous versions of the VCL that shipped with Crystal Reports are:

Subreport support

Subreports are now fully supported in the VCL via the Subreports class.

Retrieve capability

All the properties can now be filled with values from the Report using the new "Retrieve" methods.

Active Design Interface

The Object Inspector can now be used actively.  Data can be retrieved from the Report, changed, and then the Report can be run all directly from the Object Inspector without writing a line of code.

Sub-classing

Perhaps the biggest change in this Component from previous releases is the numerous sub-classing of the Report property categories.  Formulas, ParamFields, GraphType, SectionFormat, LogOnInfo, just to name a few, have all been sub-classed so that it is no longer necessary to pass long strings of semi-colon delimited data.  The new sub-classes also gave us the ability to standardize the methods associated with each class, so that they have the same name and the same function.  In practical terms, this means that once the behaviour of one sub-class is understood, it should be quite easy to understand the other classes, since they behave the same way.

New Events

New Events have been added:

OnJobOpened

OnExecuteBegin

OnExecuteDoneSend

OnExecuteEnd

OnWindowClose

OnPrintEnded

OnError

As well, 22 new Preview Window callback Events are also available to owners of Crystal Reports 6.0:

wOnActivateWindow

wOnCancelBtnClick

wOnCloseBtnClick

wOnCloseWindow

wOnDeActivateWindow

wOnDrillDetail

wOnDrillGroup

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnReadingRecords

wOnRefreshBtnClick

wOnSearchBtnClick

wOnShowGroup

wOnStartEvent

wOnStopEvent

wOnZoomLevelChange

Back to Start


Installation

See also	Delphi2	Delphi 3,4,5	C++Builder

Delphi 2

Installing the Component

1. Select Component | Install from the Delphi Main Menu.

2. Select Add from the Install Components Dialog Box.

3. Browse Files of type unit (*.DCU).

4. Select the UCRPEREG.DCU file.

5. Click OK (in the Add Module dialog to return to the Install Components dialog).  The directory where UCRPEREG.DCU is selected will automatically be installed in the Component Search Path.

6. Select OK (in the Install Components dialog).  When Delphi is finished rebuilding the Component Library, a Crystal Reports icon will appear on the Data Access page of the Component Palette.

Installing the Help file

1. Copy the UCRPE32.HLP, UCRPE32.CNT, and UCRPE32.KWF to the Delphi2 Help directory.

2. Run the HELPINST.EXE from the Delphi2 Help/Tools directory.

3. Choose File | Open and load the DELPHI.HDX file (normally in the Delphi2 Bin directory).

4. Click on the + button, or choose Add Keyword File... from the Keywords menu.

5. Choose the UCRPE32.KWF file that you copied to the Delphi2/Help directory, and then click OK.

6. Choose File | Save and then File | Exit.  Context-sensitive help should now be available from the Delphi2 IDE (choosing the F1 key while a property is selected should bring up the appropriate item in the UCRPE32.HLP file).

Delphi 3,4 & 5

Installing the Component

The Component can be installed in one of the three ways described below.

  A.  The package included (DPL/BPL) can be directly installed.

  B.  The component (UCRPEREG.DCU or UCRPEREG.PAS) can be installed into a new package.*

  C.  The component (UCRPEREG.DCU or UCRPEREG.PAS) can be installed into another package.*

*Note

When installing into a Runtime Only package, use the UCRPE32.DCU or UCRPE32.PAS units instead.

A. Installing the included Package

1. Go to the Component menu, choose Install Packages.

2. Choose Add.

3. Locate the CRYSTAL.DPL (or CRYSTAL.BPL) file and load it.

4. Choose OK.

The Crystal VCL should appear under the Data Access tab of the VCL Component palette.

B. Installing the Component into a new Package

1. Go to the Component menu, choose Install Component.

2. Choose the Into new package tab.

3. Browse the Unit file name to locate the UCRPEREG.DCU.

4. Browse the Package file name to set the destination for the new package.

5. Enter a descriptive line in the Package description area.  This description will appear in the list of installed packages.

6. Choose OK, then Yes to the prompts that follow.

The Crystal VCL should appear under the Data Access tab of the VCL Component palette.

C. Installing the Component into an existing Package

We don't particularly recommend this method, because if you install the Component into one of the Delphi standard packages, we don't know any way, short of reinstalling Delphi, to get it out of those packages!  But here are the steps:

1. Go to the Component menu, choose Install Component.

2. Choose the Into existing package tab.

3. Browse the Unit file name to locate the UCRPEREG.DCU.

4. Choose OK, then Yes to the prompts that follow.

The Crystal VCL should appear under the Data Access tab of the VCL Component palette.

Important Note

It is also necessary to add the Crystal VCL install path to Delphi's Library Path string (Tools | Environment Options | Library) in order for the Component files to be found by Delphi.

Installing the Help file

Method 1 - Delphi 4/5

With Delphi 4 and 5, the preferred way to install context-sensitive Help is by using the built-in OpenHelp installer:

1. Copy the UCRPE32.HLP and UCRPE32.CNT to the Delphi Help directory.

2. Run Delphi and go to the Help menu.  Choose Customize (the OpenHelp installer can also be run outside the Delphi environment by going to the Delphi Bin directory and running OpenHelp.exe).

3. With the Contents tab selected, right-click (or go to the Edit menu) and choose Add Files.  Locate the UCRPE32.CNT file and add it to the list.

4. With the Index tab selected, right-click (or go to the Edit menu) and choose Add Files.  Locate the UCRPE32.HLP file and add it to the list.

5. Choose File | Save Project.

Method 2 - Delphi 3/4

For Delphi 3 and 4, we have also provided a Help Installer program that can be used to automate the process.  See the UCRPEHLP.EXE in the HelpInstaller directory.

Method 3 - Delphi 3/4

With Delphi 3 and 4, context-sensitive Help can also be manually installed by following these steps:

1. Copy the UCRPE32.HLP and UCRPE32.CNT to the Delphi Help directory.

2. Load the DELPHI3.CFG file (or DELPHI4.CFG for Delphi 4), located in the Delphi/Help directory, into an editor such as Notepad.  At the bottom of the file, you will see something like this:

; Third-party Help

;-----------------

:Link quickrpt.hlp

:Link teechart.hlp

:Link imagedit.hlp

3. Add the following line to the bottom of the Third-party Help section:

:Link Ucrpe32.hlp

4. Save the DELPHI3.CFG (or DELPHI4.CFG) file.

5. Load the DELPHI3.CNT (or DELPHI4.CNT) file (located in the Delphi/Help directory) into an editor such as Notepad.  At the top of the file you will see something like this:

:Base delphi3.HLP>main

:Title Delphi Help

; Index section

;==============

:Index VCL Object and Component Reference=vcl3.hlp

:Index Object Pascal Reference=obpascl3.hlp

At the bottom of the Index section add the following line:

:Index Crystal Reports Component Help=ucrpe32.hlp

6. Go to the bottom of the DELPHI3.CNT (or DELPHI4.CNT) file and you should see an "Include section" something like this:

; Include section

;================

:include vcl3.cnt

:include obpascl3.cnt

:Include win32sdk.toc

:Include winhlp32.cnt

At the bottom of the Include section add the following line:

:Include ucrpe32.cnt

Context-sensitive Help should now be available from the Delphi IDE (choosing the F1 key while a property is selected should bring up the appropriate item in the UCRPE32.HLP file).  Also, the Crystal Component Help will be available from the Delphi Help file Contents list, and Index list.  As well, pressing F1 on an item in the Delphi code window should bring up the corresponding item in the Crystal Component Help file.

C++ Builder 1

Installing the Component

1. Go to the directory where the component files were extracted and open the FromDelphi directory.  Inside this directory are two other directories, Include and Lib.  These contain some files that need to be copied to the Include and Lib directories in your C++ Builder 1 directory.  Do not attempt to install the component until these files have been copied.

2. Add the path to the Crystal VCL component files to the Options | Environment... | Library | Library path in C++ Builder.

3. Select Component | Install from the C++ Builder Main Menu.

4. Select Add from the Install Components Dialog Box.

5. Browse Files of type unit (*.OBJ).

6. Select the UCRPE32.OBJ file.

7. Click Open (in the Add Module dialog to return to the Install Components dialog).  The directory where UCRPE32.OBJ is selected will automatically be installed in the Component Search Path.

8. Select OK (in the Install Components dialog).  When C++ Builder is finished rebuilding the Component Library, a Crystal Reports icon will appear on the Data Access page of the Component Palette.

Note

When compiling a project using the VCL, it will be necessary to add the path to the component files to the Project | Directories/Conditionals | Include and Library paths also, if they are not already on the C++ Builder search path for the project.

Installing the Help file

1. Copy the UCRPE32.HLP and UCRPE32.CNT to the C++ Builder 1 Help directory.

2. Load the BCB.CNT file, located in the C++Builder/Help directory, into an editor such as Notepad.  Go to the last ":Index" entry and add the following line:

:Index Seagate Crystal Reports VCL=ucrpe32.hlp

3. Load the BCBMAIN.CNT file, located in the Delphi/Help directory, into an editor such as Notepad.  Go to the last ":INCLUDE" entry and add the following line:

:INCLUDE ucrpe32.cnt

Context-sensitive Help should now be available from the BCB IDE (choosing the F1 key while a property is selected should bring up the appropriate item in the UCRPE32.HLP file).  Also, the Crystal Component Help will be available from the BCB Bookshelf Help file Contents list, and Index list.  As well, pressing F1 on an item in the BCB code window should bring up the corresponding item in the Crystal Component Help file.

C++ Builder 3 & 4

Installing the Component

The Component can be installed in one of the three ways described below.

A. The package included (BPL) can be directly installed.

B. The component source (UCRPEREG.PAS) can be installed into a new package.

C. The component source (UCRPEREG.PAS) can be installed into another package.

Important Note

Before attempting to install the VCL, go to the directory where the component files were extracted and open the FromDelphi directory.  Inside this directory are two other directories, Include and Lib.  These contain some files that need to be copied to the Include and Lib directories in your C++ Builder 3 directory.  Do not attempt to install the component until these files have been copied.

A. Installing the included Package

1. Go to the Component menu, choose Install Packages.

2. Choose Add.

3. Locate the BCCRYSTAL.BPL file and load it.

4. Choose OK.

The Crystal VCL should appear under the Data Access tab of the VCL Component palette.

B. Installing the Component into a new Package

1. Go to the Component menu, choose Install Component.

2. Choose the Into new package tab.

3. Browse the Unit file name to locate the UCRPE32.OBJ.

4. Browse the Package file name to set the destination for the new package.

5. Enter a descriptive line in the Package description area. This description will appear in the list of installed packages.

6. Choose OK, then Yes to the prompts that follow.

The Crystal VCL should appear under the Data Access tab of the VCL Component palette.

C. Installing the Component into an existing Package

1. Go to the Component menu, choose Install Component.

2. Choose the Into existing package tab.

3. Browse the Unit file name to locate the UCRPE32.OBJ.

4. Choose OK, then Yes to the prompts that follow.

The Crystal VCL should appear under the Data Access tab of the VCL Component palette.

Note

The path to the Crystal VCL component files must be listed in the Options | Environment... | Library | Library path in C++ Builder.  If it is not there, add it.

Installing the Help file

There are a few ways to install context-sensitive Help within the BCB3 environment.  By far the easiest method is to use the built-in OpenHelp installer:

1. Copy the UCRPE32.HLP and UCRPE32.CNT to the BCB3 Help directory.

2. Run BCB3 and go to the Help menu.  Choose Customize (the OpenHelp installer can also be run outside the BCB3 environment by going to the BCB3 Bin directory and running OpenHelp.exe).

3. With the Contents tab selected, right-click (or go to the Edit menu) and choose Add Files.  Locate the UCRPE32.CNT file and add it to the list.

4. With the Index tab selected, right-click (or go to the Edit menu) and choose Add Files.  Locate the UCRPE32.HLP file and add it to the list.

5. Choose File | Save Project.

Context-sensitive Help should now be available from the BCB IDE (choosing the F1 key while a property is selected should bring up the appropriate item in the UCRPE32.HLP file).  Also, the Crystal Component Help will be available from the BCB Help file Contents list, and Index list.  As well, pressing F1 on an item in the BCB code window should bring up the corresponding item in the Crystal Component Help file.

Back to Start


Known Problems

See also

Retrieving ParamFields from a Subreport

There is a known problem with the CRPE32.DLL of Crystal 7.0 when attempting to retrieve ParamFields when a Subreport is the current Report (ie. Subreports[n], where n is a number greater than zero).  This does not prevent access to Subreport ParamFields, since retrieving Subreports from the main Report (Subreports[0]) will retrieve the Subreport Parameters as well.  The only time this will be a problem is if a Subreport is being run as a separate Report (Crpe1.Subreports.SubExecute := True), and the Subreports class is pointing to a Subreport when the ParamFields.Retrieve method is called.  If you need to do this, do not use the ParamFields.Retrieve method, simply build your ParamFields items manually with the Add method.  We recomend that you obtain the Seagate Crystal Reports 7 Maintenance Release, as the problem has been fixed in that update.

DialogParent and Temporary Forms

If the DialogParent property is set to a temporary Form, the Report is run, and then the temporary Form is destroyed, attempting to run the Report a second time will cause an Access Violation in CRPE32.DLL.  This is because the CRPE stores the address of the DialogParent as long as the PrintJob is open.  There seems to be no way, at this time, to set the CRPE's Dialog Parent memory location back to nil.  There are a number of ways around this:

1. Set the DialogParent property of the VCL to a valid Form before running the Report a second time.

2. Close the Print Job (Crpe1.CloseJob) and open it again to run it the second time.

Error in File Links

This problem can occur with a native PC-type database connection (Paradox, dBase, Access) and a Report with more than one linked tables, especially if the file locations are being changed at runtime or the database is being verified.  The problem seems to be a combination between the new database driver DLL's (P2BBDE, P2BXBSE, etc) and the new CRPE32.DLL.  Many of these issues have been fixed in the Seagate Crystal Reports 7 Maintenance Release, which is now available.

Record Selection returns no records

This usually occurs with Crystal 7.0 and Paradox tables.  If the same selection formula worked in Crystal 6, but now fails in Crystal 7, it indicates a problem we are experiencing with the P2BBDE that was released with Crystal Reports 7, particularly regarding Date fields.  If you don't need the DateTime field support that was introduced with the SCR7 version of P2BBDE, we recommend that you go back to the Crystal 6 version of P2BBDE.  There was a partially fixed version of P2BBDE prepared, but this had other problems (if you'd like to try that version please contact Crystal Reports Technical Support).  The straight facts on this matter are that the P2BBDE.DLL is not perfect, and is not receiving a large share of development effort at this time.  If you are running into unresolvable problems using Paradox tables and Crystal Reports, consider using another database type (export your Paradox data to a DBF and Report off that), another database driver (ODBC?), or another Reporting tool.

Back to Start


Technical Support

See also	Known Problems

Further help with Technical problems (including installation, implementation, and distribution of the VCL) can be obtained in the following ways:

Phone: (604) 669-8379  Monday to Friday, 8:00am to 5:00pm, PST

Email: answers@seagatesoftware.com

Web Email Form: http://community.seagatesoftware.com

Fax: (604) 681-7163

The latest updates to the VCL can be obtained from:

Web site: http://www.seagatesoftware.com

FTP site: ftp://ftp.img.seagatesoftware.com/pub/seagate_crystal_reports/delphi/

Enhancement requests, or code improvement suggestions for the VCL Components, can be sent direct to the programmer:

zimmerman@uniserve.com

The Seagate Crystal Reports 7 Maintenance Release is available at http://store.seagatesoftware.com, or click here:

Seagate Crystal Reports 7 Maintenance Release,

Back to Start


C++ Builder Notes

See also

The Borland C++ Builder versions of Crystal's 32-bit Delphi VCL have the same features as the Delphi VCL.  In fact, they were simply recompiled from the Delphi source code.  The C++ Builder components have slight modifications to the original Delphi source, handled by compiler directives, to make them compile and run in the BCB environment.  We do not at this time have any in-house BCB developers to modify or document the components, hence the Help file included is from the Delphi VCL using Delphi code examples.  Some notes regarding the BCB syntax are included below.

Until such time as we have an in-house developer for the BCB environment, we can only offer limited support for any problems arising from the use of these components.  Initial experience indicates that Borland did a pretty good job of making sure Delphi components would work in C++ Builder.  There was one slight problem with an internal method we were using called "GetPrinter" which C++ Builder was translating to "GetPrinterA" (mistaking our method for the WinAPI call) when it compiled the OBJ file.  This has been fixed in the (to fix it, we just had to rename our internal method to something other than "GetPrinter").

Note that it is always possible to use direct Print Engine calls to our CRPE32.DLL using the CRPE.H and other header files included with Crystal Reports, or the Crystal Reports Ole Automation object, as alternatives.

Installation

See the Installation section for install procedures.

Code Syntax

The general guidelines for translating the Delphi code examples (in the Help file) to BCB are as follows:

1. Use the equals sign (=) instead of the colon-equals sign (:=) for assignment, and use the arrow pointer (->) instead of Delphi's dot (.) to specify class members.

//Delphi

Crpe1.DetailCopies := 3;

//C++Builder

Crpe1->DetailCopies = 3;

2. Use double quotes ("test") instead of single quotes ('test') for strings, and use double slashes for directories (\\) instead of single slashes (\).

//Delphi

Crpe1.ReportName := 'C:\Report1.rpt';

//C++Builder

Crpe1->ReportName = "C:\\Report1.rpt";

3. Use the open brackets to specify a method or function that takes no parameters:

//Delphi

Crpe1.SectionFormat.Retrieve;

//C++Builder

Crpe1->SectionFormat->Retrieve();

4. For default array properties, use the name of the array property instead of just the array brackets:

//Delphi

Crpe1.SectionFormat[1].BackgroundColor := clRed;

//C++Builder

Crpe1->SectionFormat->Item[1]->BackgroundColor = clRed;

More Examples

Here are a few more brief examples that show the proper syntax for using the VCL.  We recommend that you refer to the Help file for a reference as to what the actual component properties do.

Set Report Name:

Crpe1->ReportName = "d:\\7Company.rpt";

Retrieve Server Information and set Password:

Crpe1->Connect->Retrieve();

Crpe1->Connect->Password = "password";

Test the Connection:

if (Crpe1->Connect->Test())

  ShowMessage("Test Succeeded");

else

  ShowMessage("Test Failed");

Retrieve and set Parameter Fields:

Crpe1->ParamFields->Retrieve();

//According to which parameter field you want, you can set the

//ItemIndex (first parameter starts at 0) and have the ability

//to directly change the Value in this field:

Crpe1->ParamFields->ItemIndex = 0;

Crpe1->ParamFields->Value = "CA";

Retrieve SectionFormat and set BackgroundColor to Red for the Details section:

Crpe1->SectionFormat->Retrieve();

Crpe1->SectionFormat->Section = "D";

Crpe1->SectionFormat->BackgroundColor = clRed;

//The default array property Item can also be used, but Delphi

//seems to handle this more neatly..or am I missing something?

Crpe1->SectionFormat->Item[1]->BackgroundColor = clGreen;

Run the Report:

Crpe1->Execute();

Back to Start


Programming Introduction

See also

About the New VCL

The Crystal Reports Component is a Delphi VCL component that encapsulates the functionality available in the Crystal Reports Print Engine DLL (CRPE32.DLL).  It has been recently re-designed to take advantage of the VCL's object-oriented capability.

Delphi programmers have had access to the CRPE directly through the CRPE32.PAS header file for quite a few years, but the VCL component has lagged behind in functionality, especially since the introduction of Crystal Reports 5, with it's Subreport capability.  This new component adds that functionality, and much more.  In fact, it now has practically all the functionality of the Print Engine!

We have not had the time to implement full backward-compatibility, so programmers wishing to use this new VCL will need to have Crystal 5 (108 release) or higher.

Basic instruction

Programmers who are new the Crystal Reports Print Engine, will want to spend a few moments reading the next few paragraphs.  After installing the VCL, you should see the Crystal Reports component icon on the Data Access tab of the VCL palette.  Start a new project, and add the VCL to the Form.

After adding the VCL to the form, there are only two basic calls that need to be made in order to run a Report.  First let's add a Button to our new Form.  Double-click the Button to start an OnClick event in the code for the Form.  Inside the OnClick event, type the following two lines:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Execute;

Change 'C:\Company.rpt' to point to a valid Crystal Report file that exists on your computer.  Now compile the new Project and run it.  When it appears, click on the Button.  If all goes well, you should see a Crystal Report appear in our runtime Preview Window.  It really is that easy!

You will want to remember a basic rule at this point:  always set the ReportName property first!  The reason for this is that when the value of ReportName changes, most of the other properties are cleared.  This is more fully explained in the Programming Tips section of this Help file, but we simply mention it for now.

The next property you may want to experiment with is the Output property.  By default this is set toWindow, but you can also set it toPrinter, or toExport.  This can be done in code or on the Object Inspector.  If you are setting it in code, be sure to do this before the Execute command, or it will be ignored until the next Execute is called:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

Crpe1.Execute;

The following lists show which properties control the options that are available for each Output type:

toWindow	toPrinter	toExport

WindowButtonBar 	Printer	Export

WindowSize 	PrintOptions	ProgressDialog

WindowState 	ProgressDialog

WindowStyle

WindowZoom

Once you are familiar with these options, you will want to consider changing the other properties that affect how the Report processes.  Many of the options that are used to build a Report can be changed via the runtime Print Engine.  The following list gives the name of the option in the Crystal Reports Designer, and it's equivalent in the Crystal Reports component:

Crystal Reports	Crystal Reports Component

Database Location	Tables

Export	Export

Email	Export.Email

Font	SectionFont

Format Section	SectionFormat

SectionFormatFormulas

AreaFormat

AreaFormatFormulas

SectionHeight

Formulas	Formulas

Graph features 	GraphType

GraphText

GraphOptions

GraphData

GraphOptionInfo

GraphAxis

Grouping	GroupCondition

GroupOptions

LogOn Information 	Connect

LogOnInfo

LogOnServer	LogOnServer

Page Setup / Page Margins	Margins

Parameter Fields	ParamFields

Passwords: MS Access  	SessionInfo

Passwords: Paradox 	Tables

Print Date	PrintDate

Printer Setup	Printer

PrintOptions

Report Comments	SummaryInfo

Report Options	ReportOptions

Report Title	ReportTitle

Selection Formula: Group	GroupSelection

Selection Formula: Record	Selection

Sort Records  	SortFields

GroupSortFields

SQL Query	SQL

SQL Expressions	Expressions

Stored Procedure Parameters	Params

Subreports	Subreports

Summary Info	SummaryInfo

Before attempting to use these properties, please read the following section, "Dealing with SubClass Objects".

Dealing with SubClass Objects

Since the architecture of the VCL has changed quite a bit from previous releases, here is a brief programming introduction to acquaint you with the changes.  As mentioned in the Introduction, the main change in the architecture is the implementation of numerous sub-classes.

An Example: the Tables object

For example, the Tables sub-class now encapsulates all the functionality of what was called "Datafiles"  and "DatafilesLocation" in the previous releases.  This sub-class consists of 10 properties and 8 methods.  Of the 10 properties, the most essential are these 3:

Number

Name

Path

Formerly, the Datafiles property was programmed like this:

Crpe1.Datafiles[0] := 'c:\MyNewPath\MyNewTable.dbf';

Where the subscript "[0]" represented the Table Number, 'c:\MyNewPath\' represented the Path, and 'MyNewTable.dbf' represented the Table Name.  With the new VCL, the Tables object would be used instead of the Datafiles stringlist.  So the same statement would be coded like this:

Crpe1.Tables.Add(0);

Crpe1.Tables.Path := 'c:\MyNewPath\';

Crpe1.Tables.Name := 'MyNewTable.dbf';

The Add method instructs the Tables object to add an item with Table number zero.  Instead of this, we could use the Retrieve method, which retrieves all the Table information from the Report (this is the same as what was formerly called "RetrieveDatafiles"):

Crpe1.Tables.Retrieve;

After Retrieve has been called, we need to tell the Tables object to navigate to the item whose properties we wish to change.  This is necessary because the Tables object only looks at one Table at a time.  Think of it as something similar to scrolling through the records of a database.  There are a number of properties that can be used to navigate through the object: Item, ItemIndex, and Number.

Each object in the Crystal VCL that can contain more than one item, uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (LogOnInfo[2], for example), or whenever the key property (if applicable) is assigned a new lookup value.  Key properties are things like Formulas.Name, or SortFields.Number; properties that contain a unique value for each item, and which serve as look-up properties.  They appear as drop-down lists in the Object Inspector.

Number is the key property for the Tables object.  Assigning a new value to the Number property will not overwrite the value stored there, but will rather cause the Tables object to try and find that new value, and point to the Table that has the value.  For example:

Crpe1.Tables.Number := 2;

This will cause the Tables object to look internally for a Table with the number 2.  If it finds it, the object will now point it's properties to that Table and will remain pointing there until it is changed.  That is one way of navigating through the Tables.

The ItemIndex property can also be used to navigate through the Tables object:

Crpe1.Tables.ItemIndex := 2;

Although in this case, ItemIndex represents the position of the Table in the internal Tables list, not necessarily the Table Number (although if Retrieve is used, these should be the same).

By far the easiest and most natural way of navigating through the Tables object is the default array property, Item.  Since this is a default property, it does not need to be specified when making the call, so Tables[2] is the same as Tables.Item[2].  And since the Item property returns a reference to the Tables object, it is possible to add other properties to the end of the subscript:

Crpe1.Tables[2].Path := 'c:\MyNewPath\';

Crpe1.Tables[3].Name := 'MyNewTable.dbf';

While initially this might seem like a lot more work, it actually is much more powerful, especially when dealing with items that have a dozen properties, such as the SectionFormat object.  With SectionFormat, the old method involved passing a large string of about a dozen items separated by semicolons.  Even if we only wanted to set one property, we still had to pass the whole string, and hope that we got all the items in the proper order.  With the new object format, we only need to set the property that we want to change.

There are many other good reasons for making properties into objects rather than simpler stringlists, which will be seen as we proceed.

Consistent Code

One of the reasons for making the properties into objects is that the coding syntax is more consistent.  For example, we have a number of methods associated with the Tables object:

Crpe1.Tables.Retrieve;

Crpe1.Tables.Count;

Crpe1.Tables.Clear;

These are much easier to code and to remember, and more consistent, than the old calls:

Crpe1.RetrieveDatafiles;

Crpe1.GetNDatafiles;

Crpe1.Datafiles.Clear;

And since each object in the new VCL uses the same naming convention for the same methods, they are very easy to remember.  There are, of course, other good reasons for making the VCL's properties into objects, but we will see more of these reasons as we continue.

Using the Retrieve method

It is important to remember that whereas in the older versions of the VCL, most of the properties were derived from modified stringlists, and that the declaration Crpe1.Datafiles[0] would add a string to the list of subscript 0, the new VCL's sub-class objects do not work the same way.  Instead, there are two methods now used to add an item to the list.

The first, and preferred way, is to use the Retrieve method.  This retrieves the Table information from the Report, and stores it in the Tables object, so that all the necessary table items are already present, and the programmer just needs to set the object to the desired table, then change the desired properties.  This would be coded like so:

{Retrieves Tables from Report}

Crpe1.Tables.Retrieve;

{Modifies Path of first Table}

Crpe1.Tables[0].Path := 'c:\MyNewPath\';

{Modifies Name of first Table}

Crpe1.Tables[0].Name := 'MyNewTable.dbf';

Or for changing the path of more than one table at a time, a simple loop can be constructed. Since the Tables property is now an object, it was easy to add methods and properties to it that made it behave like a stringlist.  So the Count method and ItemIndex properties were added, as well as the default array property, Item.  The Item property allows us to treat the Tables object as if it were a stringlist, hence Tables[0] is equivalent to Tables.Item[0]:

{Retrieves Tables from Report}

Crpe1.Tables.Retrieve;

for cnt := 0 to (Crpe1.Tables.Count - 1) do

begin

  {Modifies Path of Table}

  Crpe1.Tables[cnt].Path := 'c:\MyNewPath\';

end;

The second way of adding items to the Tables object would be to do it manually by using the Add method.  To use this way, Retrieve is not called.  Instead it is up to the programmer to know how many tables are in the Report, or to know which Tables he wants to change.  This method would be coded like so:

{Adds Table 0 to Tables object}

Crpe1.Tables.Add(0);

{Set Path of first Table}

Crpe1.Tables.Path := 'c:\MyNewPath\';

{Set Name of first Table}

Crpe1.Tables.Name := 'MyNewTable.dbf';

Note that in the above example, it is not necessary to include the subscript [n] after the Tables object name.  This is because the Tables object has an internal index that keeps track of which Table item it is currently looking at.  This may change in the future as we improve the object-orientation of the design, so it is probably best to use the subscript so that your code will be compatible with future revisions:

{Adds Table 0 to Tables object}

Crpe1.Tables.Add(0);

{Set Path of Table just added}

Crpe1.Tables[Crpe1.Tables.Count - 1].Path := 'c:\MyNewPath\';

{Set Name of Table just added}

Crpe1.Tables[Crpe1.Tables.Count - 1].Name := 'MyNewTable.dbf';

Dealing with Subreports

If the Report has Subreports, the Subreports names can be stored in the Crystal VCL by using the Subreports object and it's Retrieve method:

Crpe1.Subreports.Retrieve;

When this call is made, a Tables object is set up for each Subreport.  The Subreport Tables are handled in exactly the same way as shown above except that you must specify which Subreport you are working with before handling the Tables object:

{Retrieves the Subreports}

Crpe1.Subreports.Retrieve;

{Sets the VCL to Subreport 1}

Crpe1.Subreports[1];

{Retrieves the Tables for Subreport 1}

Crpe1.Tables.Retrieve;

It is important (and hopefully not too confusing!) to remember that the Subreports object stores the main Report information as the first item in the object, so Subreports[0] refers to the main Report.  Of course, the Subreport object can also be handled manually through it's Add method instead of using the Retrieve method, but in most cases, this will prove to be more difficult to code and to maintain.

Here is a simple code example which illustrates how to fill the Crystal component with Report information, which can then be edited and sent back to the Print Engine:

Crpe1.ReportName := 'c:\MyCrystalReport.rpt';

Crpe1.Subreports.Retrieve;

Crpe1.Printer.Retrieve;

Crpe1.PrintOptions.Retrieve;

Crpe1.SummaryInfo.Retrieve;

for cnt := 0 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.LogOnInfo.Retrieve;

  Crpe1.Connect.Retrieve;

  {Do not do SQL Retrieve here, it slows down loading while trying to Logon to the Server.  Use the SQL.Retrieve method after filling in the Password property of the Connect or LogOnInfo objects}

  Crpe1.SQL.Params.Retrieve;

  Crpe1.Tables.Retrieve;

  Crpe1.Selection.Retrieve;

  Crpe1.GroupSelection.Retrieve;

  Crpe1.Formulas.Retrieve;

  Crpe1.ParamFields.Retrieve;

  Crpe1.GraphType.Retrieve;

  Crpe1.GraphText.Retrieve;

  Crpe1.GraphData.Retrieve;

  Crpe1.GraphOptionInfo.Retrieve;

  Crpe1.GraphAxis.Retrieve;

  Crpe1.SectionFormat.Retrieve;

  Crpe1.SectionFormatFormulas.Retrieve;

  Crpe1.AreaFormat.Retrieve;

  Crpe1.AreaFormatFormulas.Retrieve;

  Crpe1.SectionFont.Retrieve;

  Crpe1.SectionHeight.Retrieve;

  Crpe1.SortFields.Retrieve;

  Crpe1.GroupSortFields.Retrieve;

  Crpe1.GroupOptions.Retrieve;  {or GroupCondition for Crystal 5.0}

  Crpe1.ReportOptions.Retrieve;

  Crpe1.PrintDate.Retrieve;

  Crpe1.Margins.Retrieve;

  Crpe1.RetrieveReportTitle;

  Crpe1.RetrieveDetailCopies;

end;

Please remember that the Retrieve method clears out the Sub-class object first before retrieving values from the Report, so be sure to use it at the beginning of the code that deals with that particular object.  This is the correct way:

Crpe1.Tables.Retrieve;

Crpe1.Tables[4].Name := 'MyNewTable.dbf';

And this is the wrong way:

Crpe1.Tables[4].Name := 'MyNewTable.dbf';

Crpe1.Tables.Retrieve;

How do I clear the object?

Each Sub-class object can be cleared manually via the Clear method, although this will happen automatically when the ReportName is changed, or when the CloseJob method is called, and so is not normally required.

Other Guidelines

Zero-based numbering is used throughout the Crystal component, to make it compatible with our Print Engine.  So the first Table is Table[0], the first Formula is Formulas[0], etc.  The only exception to the rule is the Group numbering, which starts with 1, just as it is in the Crystal Reports Designer.  So the various Section objects use GH1 as the first group, not GH0.  Likewise, the GroupCondition property takes 1 as the first Group for the Number property.

For numeric properties, -1 has been used as a default value.  Normally, empty strings in properties that are of string type will not be sent to the Print Engine.  If you want to send an empty string, use the CrEmptyStr or CrwNull constants, which will tell the Crystal component that you want to intentionally pass an empty string to the Report.

Back to Start


Programming Tips

See also

Always Set ReportName First!

When writing code to run a Report using the VCL component, be sure to set the ReportName property first.  The reason for this is that the VCL monitors any changes to ReportName, and when it is changed, it clears out any Subreport information as well as the following properties for the main Report:

AreaFormat

AreaFormatFormulas

Connect

DetailCopies

Formulas

GraphData

GraphOptions

GraphText

GraphType

GroupCondition

GroupOptions

GroupSelection

GroupSortFields

LogOnInfo

Margins

ParamFields

PrintDate

ReportOptions

ReportTitle

SectionFont

SectionFormat

SectionFormatFormulas

Selection

SectionHeight

SessionInfo

SortFields

SQLQuery

SQL.Params

SQL.Expressions

SummaryInfo

Tables

Therefore, if any of these properties have been set before ReportName, they will be cleared when the ReportName property is assigned a new value.

Discard Saved Data

Beware of saving Reports from Crystal Report's Designer with Saved Data turned on (this option is under the File menu, and in the Report Options dialog), unless you want them that way.  When they are run from Delphi, if you don't set the DiscardSavedData property to True, the Report will run from the Saved Data (which is the default mode), and will not show the changes that have been made to the database.

After a Report has been run via the VCL once, and the Print Job has not been closed (either via the CloseJob method or changing the ReportName property), the Report that is currently in memory now has Saved Data.  If you run it again, it will run with the Saved Data from the first run.  This means that some of the changes you pass in the second time, may not have any effect.  The solution is to set the DiscardSavedData property to True.

Note that the most recent releases of the VCL also include a DiscardData method, which accomplishes the same task as the DiscardSavedData property except that it works immediately on the open Report.

Verify Database

Under the Database menu in Crystal Reports designer, there are two menu items:  Verify Database and Verify on Every Print.  Since the Database structure and index information are stored in a Report file when it is saved, the Report may have problems running if the Database structure changes.

One solution is to load the Report into the designer, and choose Verify Database, then re-save the Report.  This is fine during development, but if the Database structure will be changing during runtime operation, there is no equivalent for these "Verify" commands in the runtime engine, unless you are using Crystal Reports 7, in which case the Verify commands have been exposed via the ReportOptions class and the VerifyDatabase method.

If you are not using Crystal Reports 7, "Verify on Every Print" should be turned on in these instances.  With this option on, the Report will re-read the Database structure every time it runs.  The amount of time taken to do this extra step is usually minimal.  If the Database structure will not change after deployment, there is no reason to turn this feature on.

Connecting to SQL Servers

With this VCL, we give you three different ways of establishing a connection to an SQL DataSource or Server:  LogOnServer, LogOnInfo, and Connect.  We recommend you review these sections in the Help file to determine which method suits your needs best.

One thing to keep in mind when connecting to SQL databases, is that if the database is being accessed via ODBC drivers in the Report, then the ServerName property of the above-mentioned methods represents the ODBC DataSource Name, not the actual Server Name.  On the other hand, if the database is being accessed via Crystal's native SQL drivers, then the ServerName property of the LogOnServer, LogOnInfo, and Connect objects represents the actual SQL Server name.

Another thing to watch for is that some table locations are stored in a Report as <db name>.<owner>.<table name>.  Attempting to change the ServerName for such a Report at runtime could cause it to look for the tables on the original Server instead of the new one, which usually results in a connection error.  One solution is to remove the <db name> and <owner> prefixes so that just the Table Name is listed.  This can be done in the Report (Set Location dialog in Crystal Reports), or via the VCL's Tables object.

Changing Tables & Formulas

When changing the Table names that a Report is based on, it is important to remember that Formula fields will use the Report's Alias name for the Table, and not the new Table name.

For example, suppose I have a Report which uses the Company1 table.  When I added Company1 to the Report, an Alias was created for it by Crystal Reports called Company1.  When I then use a field in a Formula, I see it like this:

  {company1.Field}

However, the "company1" name represents the Alias and not the actual Table name.  So, in the Delphi program, when I change the Table name from "company1" to "company2", the Formula still sees the field as {company1.Field}, and not {company2.Field}, since the Alias that Crystal Reports assigned remains the same.  Crystal Reports aliases can only be changed in the designer, not at runtime.

Changing Groups & Summary fields

When changing Grouping fields at runtime via the GroupCondition or GroupOptions object, remember that any inserted Summary fields, or Formulas containing Summary fields in the Report may cause errors, since they contain the Grouping field name as the second element of their parameters.  For example, take the following Summary field:

    Sum({company.SALES}, {company.STATE})

This formula sums the amount of Company Sales per State.  This Summary field assumes that {company.STATE} is one of the grouping fields.  If the grouping field is changed from {company.STATE} to {company.COUNTRY}, this formula field will generate an error.

The way to avoid this problem is to insert the Grouping field into a Formula field when designing the Report.  Then when you create the Group, base it on the Formula field.  Any Summary fields inserted will also look at the Formula field as the grouping field, regardless of what it contains.  Then to change the Group field at runtime, simply pass a new {table.field} value to the Formula field.  All the Summaries will automatically change.

Using the Send methods

Since the VCL's Execute method uses the Send methods from the VCL's sub-class objects, there is usually no need to call these methods in code.  However, there are at least two cases where this can be advantageous:

1. For changing the order in which items get sent to the Print Engine.  For example, the Execute method of the VCL sends the Formulas first, and then the Grouping information.  If GroupOptions.Send is called just before Execute, this has the effect of sending in the Grouping information before the Formulas.

2. For testing the VCL and/or the Print Engine.  Properties can be set and then passed from the VCL to the Print Engine by calling the Send method.  Then the values can be retrieved using the Retrieve method and examined to make sure they are getting passed correctly.

Using the JobNumber property

The Crystal Reports Print Engine (CRPE32.DLL) assigns a specific Job Number to each open Print Job.  This Job Number is used internally in the VCL component, and is used when making calls to the CRPE so that it knows which Print Job the call is going to.  Because this number is exposed in the JobNumber property of the VCL, it can be used to make direct calls to the CRPE, bypassing the VCL layer.  While this is not normally recommended, since making changes to the Print Job without the VCL knowing about the changes can lead to problems, there are also times when this can be a powerful feature.

For example, the Execute method of the VCL has Events available within it, such as OnExecuteEnd, OnPrintEnded, etc.  These events have protection which prevents the programmer from calling another Execute within the event (which would lead to an infinite loop).  However, by the use of direct Print Engine calls, this limitation can be worked around.  The call to run a Report in the Print Engine is

function PEStartPrintJob(

  JobNum        : Word;

  WaitUntilDone : Bool): Bool; stdcall;

The second parameter "WaitUntilDone" should always be True, and the first Parameter is the Print Job number, which is available in the VCL via Crpe1.JobNumber.  Therefore, making this call within the OnExecuteEnd event (just as an example, not because it is meaningful!), causes the Report to be run immediately.

For a complete list of the available Print Engine calls, consult the DEVELOPR.HLP that came with Crystal Reports, or take a look at the CRDELPHI.PAS (if you have Crystal Reports 7), or CRPE32.PAS, which are also in the Crystal Reports install directory, or some of the VCL source code files (CRDYNAMIC.PAS).

Back to Start


Frequent Questions

See also

Why won't the VCL install properly?

The solution to 95% of the calls we get in Technical Support that deal with this question is usually found in removing an older DCU, PAS, or DPL/BPL file from the Path.  If you are having problems with installation, go through the following steps:

1.	If the new VCL was installed into the same directory as a previous version without deleting the previous files first, delete the whole directory and extract the new VCL again.

2.	Open Delphi and remove all the Crystal VCL's from the current Project and Forms, and all the Crystal VCL packages or components from Delphi's VCL library.  This can be done via the Component | Install Packages dialog, by selecting the package and choosing the Remove button.

3.	Go to Tools | Environment Options and make sure no Crystal VCL's are in the Library Search Path.

4.	Go to Project | Options dialog and make sure there are no Crystal VCL's are in the search path.  Close Delphi, saving all changes.

5.	Search the computer for UCRPE32.*, UCRPE32.*, and CRYSTAL.*.  If any older copies are found, move them to a backup directory where Delphi will not find them.

6.	Start up Delphi again, and install the CrystalVCL DPL (or BPL) via the Component | Install Packages dialog.

7.	Once this is done, add the path to the new VCL onto the end of the Tools | Environment Options | Library Search Path.

Now start a new application, drop the VCL onto the form, and try another test run.

Can I run a Report based on a TTable or TQuery?

Yes and No.  With the current release of the VCL, it is possible to pass any information stored in a Delphi Form into a Crystal Report.  This is done by creating a Report using the Active Data driver.  Then at runtime, a Crystal Data Object is created, which uses a memory array to store information that is then passed to the Report.  The connection via the VCL is handled in the new DataPointer property of the Tables class.  Using this method, the TTable or TQuery (or DataGrid that has the result of the Table or Query) would have to be copied into the memory array and then attached to the Crystal Data Object, which is then attached to the Report by the VCL.

An alternative to this method, would be to write an COM wrapper for TDataSet that could then be hooked directly to the DataPointer property.  We have not attempted this yet.  The interface required is outlined in the Crystal Reports 7 Developer Help file, search the index for CRDataSource, or import the type library from CRSOURCE.TLB, which is located in the Crystal Reports directory.

As a third option, there is a VCL for Crystal Reports available from a third-party developer (SupraSoft) which has this functionality.  This VCL is available at:  http://www.suprasoft.com.  Check with them for the current price.

Do you have a Delphi3 VCL for Crystal Reports version 4.5?

No.  The original VCL was developed by third-party developers.  We could recompile it for Delphi 3 and 4 if we had the Source Code but we don't have it.  Attempts to contact the third-party developer have been fruitless.  We suggest that if you absolutely need a VCL that works with Crystal 4.5 that you either modify this one (the Source Code is included), or you obtain the one mentioned above, from SupraSoft, as theirs is backwards compatible with Crystal 4.5.

Can I use the BDE's SQL Links drivers with Crystal Reports?

We do not yet support all of the functionality of the BDE for designing Reports.  Our P2BBDE.DLL only supports Paradox and dBase tables via the BDE at the moment.  This could change in the future, but at the moment, there are no immediate plans underway to implement that functionality.  So this means that at present, your application can go to SQL tables via the BDE, but Crystal will have to go either via it's ODBC drivers, it's native SQL drivers, or an ADO/CDO connection.

Why is the new VCL not more Delphi-like?

The design of the new VCL for Crystal Reports is definitely more object-oriented than previous versions.  However, it differs from some of the Delphi VCL examples that use collections of objects, or a Collection class that contains a list of Class items.

Previous to this release, VCL development was usually handled by third-party developers.  The problems we had with this were that very few third-party developers had the time to really delve into our Print Engine to the point where they understood it well, and updates or fixes were sometimes delayed because the developers obviously had their own projects which they had to finish as well.  Initially when we started modifying the VCL, our knowledge of the Print Engine was very good, but we were fairly new to Delphi VCL design and coding.  So, we elected to choose a design that was a bit simpler than we could have made it.

The differences are:

1. We have based all our classes on TPersistent because that allows us to use the Object Inspector as an editor and visual representation of the properties of the VCL sub-classes, particularly for Delphi 2 where the Collection class is not directly supported.

2. We use an internal index integer to keep track of the currently selected Subreport, SortField, Table, etc., so that it is not necessary, for example, to specify

SortFields[3].Field

each time you want to reference the Field property for SortFields[3](although it is perfectly acceptable to do so).  You can simply specify SortFields[3] once, which sets the internal index, and then write

SortFields.Field

This may change in the future, however, so we recommend using the subscript as much as possible.

3. The Subreports class does not contain all of the other sub-classes that pertain to a Subreport, but it establishes a pointer to a Report Information structure which holds the various subclasses that pertain to a specific Report/Subreport.  Therefore, Subreports.Retrieve does not retrieve all the information from a Subreport, it simply obtains the Subreport name, and allocates the memory for a Report Info structure.  It is still neccessary to do a Tables.Retrieve, SortFields.Retrieve, etc., for the Subreport, when this information is desired.  However, we have created some Subreport functions with the same names as the other subclass objects which return a reference to those subclass objects, so syntax such as the following is possible:

Crpe1.Subreports[2].SortFields[3].Field := '{company.STATE}';

Naturally, it is also possible to update the Subreport pointer first, and then use the SortFields subclass to apply to that particular Subreport:

 	Crpe1.Subreports[2];

Crpe1.SortFields[3].Field := '{company.STATE}';

Back to Start


Distributing an Application

See also

There is no one recommended way for distributing the necessary Runtime Files for an Application that includes Reports.  Some developer's use the InstallShield Express that comes with Delphi, or another commercial install program, some use Crystal's Report Distribution Expert (although this utility does not give much control over setting of install paths), and some just manually copy the files over.  Here are a few tips that will help:

How do I know which files to distribute?

One of the best resources for determining which files to distribute is the RUNTIME.HLP file that comes with Crystal Reports.

•	You must include the files that are listed in the "Required Files" section of this Help file.  Some of these files are Microsoft DLL's and may already be on the destination machine, but if they are not, it will be your responsibility to make sure they are.

•	The next section to look at is "Database Access".  Choose only the files required for the type of database, and method of connection, that your Reports use.  If in doubt, load the Report into Crystal Reports designer, and take a look at the "Convert Database Driver" dialog (this will be under the Database menu in CRW 6.0 and in the Report Options dialog in CRW 5.0).

•	Then consider the "Exporting" section.  Will your application allow exporting of Reports?  Which formats will you include?  You only need to distribute the formats you want the users to have access to.  If you choose to distribute none of them, the Export button on the Preview Window will do nothing (it can be made invisible with the Crystal 6.0 runtime, via the WindowButtonBar object in the VCL).

•	The last two things to consider are UFL's and Graphs.  UFL's (or U2L's in 32-bit) are Formula Editor DLL's for adding special functions to the Crystal Reports Formula Editor.  As with Export DLL's, you only need to distribute the ones your Reports are using.  Most of the functions in the Formula Editor are already built in to CRPE32.DLL, but one of the more common ones that is not is the U25DTS.DLL, which has various functions for converting DateTimeString fields to DateTime format.  The Graph DLL is required only if the Reports contain graphs.

Runtime File Utilities

There are a number of utilities that come with Crystal Reports which are very useful for tackling Runtime File problems.  Some of these are installed in the same directory as CRW32.EXE, and others can be found in the Tools directory on the Install CD:

•	DEXPERT.EXE - This is the Report Distribution Expert from Crystal Reports.  With Crystal 6.0, it is a separate program.  With Crystal 5.0, you will need to run it from the Report menu of the designer (CRW32.EXE).  This program is mainly intended to simplify the distribution of Compiled Reports, which are usually used by people who do not want to do a programming interface to the runtime engine.  Hence it is of limited use to Delphi developers, but can be used to provide a list of required runtime files.  Bear in mind that it will list all available U2L's and Export DLL's, whether they are used by the Report or not.

•	DSX32.EXE - This program generates a list of loaded DLL's for a specific application which is running.  It also has a Compare option for comparing two different lists, which is very handy when you have one machine that works and another that doesn't.  This utility does not work on Windows NT.

•	RPTCHK32.EXE - The purpose of this utility is to load a Report, analyse it for the Runtime Files it requires, and then provide you with the results of the analysis.

•	CRWCHK32.EXE - This utility was meant to be run on a client machine.  You tell it what Crystal version you are distributing, and which options you want to scan for, and it will search out the DLL's and tell you if the versions are what was expected or not.  It will list all the versions of the files that it finds in the Windows search path, along with their versions, dates, and sizes.  It will also record any that it does not find.

•	SQLCON32.EXE - This utility does not actually check for Runtime Files.  It is an application which connects to ODBC and tests out ODBC Data Sources to see if they are functioning correctly.  It will retrieve lists of tables and fields from an ODBC Data Source, and run an SQL Query on a Data Source.  It's primary use is to test out ODBC connection problems on client machines.

When connecting to ODBC, there are two layers we are concerned with:  The Report's connection to ODBC via the P2SODBC.DLL, and the ODBC drivers connection to the database.  If there is a problem with runtime Reports connecting to ODBC on a client machine, we need to find out which layer is giving the problem.  If SQLCON can connect and run SQL Queries, then the problem is with P2SODBC.  It is either not being found, is the wrong version, or is corrupt.  If SQLCON cannot connect, then the problem is with the installation and setup of the ODBC drivers.

•	UPDATE60.EXE - This utility was not completed in time to ship with Crystal Reports 6.0, but is available on our web site in the File areas, General section (there is also an UPDATE50.EXE for Crystal Reports 5.0).  Update60 will not help you with Runtime File problems, but it provides an easy way to make batch changes to Reports, such as changing Printer Driver, Database Location, SQL/ODBC Data Source, and Database drivers.  Verify Database is also included, as well as Search & Replace text.  The Reports can then be saved out with the new changes.

Distributing the BDE

The RUNTIME.HLP lists the required 32-bit BDE DLL's needed on a client machine.  Remember that these must be in the Windows search path, or they will not be found.  If you are installing them in another directory which is not in the path, there is a Delphi utility (complete with source code) available on the Inprise web site called BDEREG, which can be used to update the Registry with the current path to the BDE and the path to the IDAPI.CFG file:

http://www.inprise.com/devsupport/bde/utilities.html

I Don't want to distribute the BDE.  Does the VCL require it?

The VCL does not require the BDE to run.  It has the DBTables unit (or DB for Delphi 2) in the Uses clause for the Implementation section, but unless BDE aliases are passed to the Tables.Path property, or the GetPathFromAlias method is used, the BDE will not be loaded.  We have tested it here on machines that do not have the 32-bit BDE installed, and it worked fine.  If you experience any problems in this regard, the following items can be removed from the Source Code and re-compiled (don't attempt this if you are not at least slightly familiar with component creation):

1. Remove DBTables (DB for Delphi 2) from the Uses clause in UCRPE32.PAS.

2. Remove the declaration and function code for GetPathFromAlias.

3. Remove the following from the TCrpeTables.Send procedure (it occurs twice):

{Convert Paths with BDE Aliases to directories}

if sLoc[1] = ':' then

  sLoc := Cr.GetPathFromAlias(sLoc);

Back to Start


Properties

See also

These are the Properties that belong specifically to the TCrpe class.  Each Sub-class also has it's own Properties which can be viewed by going to the help for that particular Sub-class.

 Read-only

 Run-time only

 Design-time only

 SubClass property

About

AreaFormat

AreaFormatFormulas

CanCloseEngine

Connect

ConnectMethod

CrpePath

DesignControls

DetailCopies

DialogParent

DiscardSavedData

Export

Expressions

FieldMapping

Formulas

GraphAxis

GraphData

GraphOptionInfo

GraphOptions

GraphText

GraphType

GroupCondition

GroupOptions

GroupSelection

GroupSortFields

HasSavedData

IsJobFinished

JobNumber

LastErrorNumber

LastErrorString

LoadEngineOnUse

Log

LogOnInfo

LogOnServer

Margins

Output

Pages

ParamFields

PrintDate

PrintEnded

Printer

PrintOptions

ProgressDialog

Records

ReportName

ReportOptions

ReportTitle

SectionFont

SectionFormat

SectionFormatFormulas

SectionHeight

Selection

SendOnExecute

SessionInfo

SortFields

SQL

Status

Subreports

SummaryInfo

Tables

Version

WindowButtonBar

WindowCursor

WindowEvents

WindowParent

WindowSize

WindowState

WindowStyle

WindowZoom


Properties : Also
See also

Properties by Group

Methods by Group

Methods

Events

Utility Methods

Back to Start


Methods

See also

These are the Methods that belong specifically to the TCrpe class.  Each Sub-class also has it's own Methods which can be viewed by going to the help for that particular Sub-class.

CancelJob

Clear

CloseEngine

CloseJob

CloseWindow

CopyFrom

Create

Destroy

DiscardData

Execute

ExportWindow

Focused

HideWindow

LogOnPrivateInfo

OpenEngine

OpenJob

PrintWindow

ReportWindowHandle

RetrieveDetailCopies

RetrieveFieldMapping

RetrieveReportTitle

RetrieveWindowState

SendDetailCopies

SendDialogParent

SendDiscardSavedData

SendFieldMapping

SendOutput

SendProgressDialog

SendReportTitle

SetFocus

ShowWindow

VerifyDatabase


Methods : Also
See also

Methods by Group

Properties by Group

Properties

Events

Utility Methods

Back to Start


Events

See also

Regular Events

OnCreate

OnError

OnExecuteBegin

OnExecuteDoneSend

OnExecuteEnd

OnFieldMapping

OnGetVersion

OnJobOpened

OnPrintEnded

OnPrinterSend

OnWindowClose

Window Events

There are 23 Preview Window callback events, prefixed with "w" (for Window Events).  These are activated when the WindowEvents property is set to True.  These events allow a Delphi application to respond to actions that take place on the Preview Window, such as button clicks and drill-down events.

wOnActivateWindow

wOnCancelBtnClick

wOnCloseBtnClick

wOnCloseWindow

wOnDeActivateWindow

wOnDrillDetail

wOnDrillGroup

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnReadingRecords

wOnRefreshBtnClick

wOnMouseClick

wOnSearchBtnClick

wOnShowGroup

wOnStartEvent

wOnStopEvent

wOnZoomLevelChange

Note

WindowEvents are only available with Seagate Crystal Reports 6 or higher.  The wOnRightMouseClick event is only available with SCR 7 or higher.


Events : Also
See also

Properties by Group

Methods by Group

Properties

Methods

Utility Methods

Back to Start


Properties by Group

See also

Engine

LoadEngineOnUse

Error

LastErrorNumber

LastErrorString

Export

Export

Formulas

AreaFormatFormulas

Formulas

GroupSelection

ParamFields

SectionFormatFormulas

Selection

General

About

CrpePath

DesignControls

FieldMapping

Log

ProgressDialog

Graphs

GraphAxis

GraphData

GraphOptionInfo

GraphOptions

GraphText

GraphType

Group/Sort

GroupCondition

GroupOptions

GroupSortFields

SortFields

Margins

Margins

Pages

Pages

PrintDate

PrintDate

Printer

Printer

PrintOptions

PrintJob

CanCloseEngine

IsJobFinished

JobNumber

PrintEnded

SendOnExecute

Status

Records

Records

Report

DetailCopies

DiscardSavedData

HasSavedData

Output

ReportName

ReportOptions

ReportTitle

Sections

AreaFormat

SectionFont

SectionFormat

SectionHeight

SessionInfo

SessionInfo

Subreports

Subreports

SQL

Connect

ConnectMethod

Expressions

LogOnInfo

LogOnServer

Params

SQL

SummaryInfo

SummaryInfo

Tables

Tables

Version

Version

Window

DialogParent

WindowButtonBar

WindowCursor

WindowEvents

WindowParent

WindowSize

WindowState

WindowStyle

WindowZoom


Properties by Group - See also
See also

Methods by Group

Properties

Methods

Events

Utility Methods

Back to Start


Methods by Group

See also

These are the Methods that belong specifically to the TCrpe class.  Each Sub-class also has it's own Methods which can be viewed by going to the help for that particular Sub-class.

Constructor/Destructor

Create

Destroy

General

Clear

CopyFrom

Engine

OpenEngine

CloseEngine

PrintJob

OpenJob

CloseJob

CancelJob

DiscardData

Execute

Retrieve procedures

RetrieveDetailCopies

RetrieveReportTitle

RetrieveFieldMapping

Send procedures

SendDetailCopies

SendDialogParent

SendDiscardSavedData

SendFieldMapping

SendOutput

SendProgressDialog

SendReportTitle

SQL

LogOnPrivateInfo

Tables

VerifyDatabase

Window

CloseWindow

Focused

HideWindow

ExportWindow

PrintWindow

ReportWindowHandle

RetrieveWindowState

SetFocus

ShowWindow


Methods by Group - See also
See also

Properties by Group

Properties

Methods

Events

Utility Methods

Back to Start


TCrpe Component menu
Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Utility Methods
Utility Methods (UCrpeUtl)

See also

These Methods are used by the Crystal Reports VCL but are in a separate Unit, since they are general purpose functions that may be useful to developers while using the Crystal Reports VCL.  If you wish to use some of these functions, be sure to add UCrpeUtl to the USES clause of your Delphi unit.

String Handling

AddBackSlash

GetErrorNum

GetErrorStr

GetPathFromAlias

GetStrFromRsc

GetToken

IsNumeric

IsStrEmpty

TruncStr

String Conversion - Boolean

CrBooleanToStr

CrStrToBoolean

String Conversion - Floating

CrFloatingToStr

CrStrToFloating

String Conversion - Date

CrDateToStr

CrStrToDate

ExDateStr

String Conversion - DateTime

CrDateTimeToStr

CrStrToDateTime

ExDateTimeStr

String Conversion - Time

CrTimeToStr

CrStrToTime

ExTimeStr

String Conversion - SectionCode

SectionCodeToStr

StrToSectionCode

String Conversion - ValueInfo

StrToValueInfo

ValueInfoToStr

Index Checking

IndexInRange

IndexValid

Miscellaneous

CopyDevMode

GetVersionInfo

RGBToColor

RTrimList


Utility Methods - See also
See also

Properties by Group

Properties

Methods by Group

Methods

Events

Back to Start


Version

See also	Properties & Methods	Example

Declaration

property Version: TCrpeVersion;

Type

TCrpeVersion = class(TPersistent)

Description

The Version property is a Sub-class that contains properties which display the version numbers of the CRPE32.DLL, the Crystal Reports Print Engine, and the Operating System:

•	The DLL property contains the CRPE32.DLL internal version number.

•	The Engine property contains the CRPE32.DLL internal engine number.

•	The Windowsproperty contains the current Windows operating system version.

•	The FileVersion property contains the full CRPE32.DLL file version number (as a string).

•	The Major property contains the first number sequence of the file version string (as an integer).

•	The Minor property contains the last number sequence of the file version string (as an integer).

The Version properties are useful for checking to make sure the proper DLL/Engine is loaded.  They are also used internally in the VCL for:

- The ParamFields object, which requires Crystal 5.0 (108 release) or later.

- The WindowButtonBar (except for the Visible property, which applies to Crystal 5 and up).

- The SummaryInfo, WindowEvents, and GroupOptions, which only apply to Crystal 6.0.

- The Excel Export options, the new ParamFields properties and ParamFields Info and Ranges objects, the SQL Expressions object, the ReportOptions object, the wOnMouseClick event, the VerifyDatabase method and FieldMapping property, the OnFieldMapping event, and the OutputFileName property of PrintOptions, all of which only apply to Crystal 7.

Note

Although not normally recommended, the Major and Minor version numbers can be over-ridden in the OnGetVersion event.


Version - See also
Related

OnGetVersion

ParamFields

SummaryInfo

WindowButtonBar

WindowCursor

WindowEvents

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Version - Properties & Methods
Version:

Properties & Methods

Version	TCrpe Component

Properties

DLL

Engine

FileVersion

Major

Minor

Windows

Methods

Clear

CopyFrom

Retrieve

Constructor

Create


Version - Example
Example

The following example checks to see if the version of the CRPE32.DLL is greater than 5.  If it is, the WindowButtonBar buttons can be made visible/invisible.

if StrToInt(Crpe1.Version.DLL[1]) > 5 then

  Crpe1.WindowButtonBar.AllowDrillDown := True;


DLL property

See also	Example

Applies to

Version

Declaration

property DLL: string;

Description

The DLL property is a read-only property that contains the DLL version number of the CRPE32.DLL which is currently open.

The DLL property can be used whenever you build functionality into a Report that may not be available in earlier versions of the Crystal Report Engine and you need to verify the version number first.  This property can also be a handy safeguard for users who have more than one version of the Crystal Report Engine with the older version earlier in the path than the new version.

Note

There is some internal protection built into the VCL which will prevent operation if a CRPE32.DLL earlier than 5.x.x.108 attempts to load.

The SummaryInfo object, the WindowEvents, the WindowCursor object, and most of the WindowButtonBar options (except for Visible), will only work with Crystal Reports 6.0, and the ParamFields object requires the last maintenance release of 5.0: 5.0.x.108.


DLL property - See also
Related

Engine

FileVersion

Major

Minor

Windows

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DLL property - Example
Example

The following example checks to see if the version of the CRPE32.DLL is greater than 5.  If it is, the WindowButtonBar buttons can be made visible/invisible.

if StrToInt(Crpe1.Version.DLL[1]) > 5 then

  Crpe1.WindowButtonBar.AllowDrillDown := True;


Engine property

See also	Example

Applies to

Version

Declaration

property Engine: string;

Description

The Engine property is a read-only property that contains the Engine version number of the CRPE32.DLL which is currently open.

The Engine property can be used whenever you build functionality into a Report that may not be available in earlier versions of the Crystal Report Engine and you need to verify the version number first.  This property can also be a handy safeguard for users who have more than one version of the Crystal Report Engine with the older version earlier in the path than the new version.

Note

There is some internal protection built into the VCL which will prevent operation if a CRPE32.DLL earlier than 5.x.x.108 attempts to load.

The SummaryInfo object, the WindowEvents, the WindowCursor object, and most of the WindowButtonBar options (except for Visible), will only work with Crystal Reports 6.0, and the ParamFields object requires the last maintenance release of 5.0: 5.0.x.108.


Engine property - See also
Related

DLL

FileVersion

Major

Minor

Windows

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Engine property - Example
Example

The following example checks to see if the version of the CRPE32.DLL is greater than 5.  If it is, the WindowButtonBar buttons can be made visible/invisible.

if StrToInt(Crpe1.Version.Engine[1]) > 5 then

  Crpe1.WindowButtonBar.AllowDrillDown := True;


Windows property

See also	Example

Applies to

Version

Declaration

property Windows: string;

Description

This property provides a formatted string that contains the version of Windows currently being used.  It is provided for general use, where certain features of an application may require different code if used on Windows95 or WindowsNT.

The string is formatted with the Windows version first, ie. "95", then a slash character: "/", then the Windows release number, ie. "4.0".


Windows property - See also
Related

DLL

Engine

FileVersion

Major

Minor

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Windows property - Example
Example

The following example uses the utility function GetToken (in UCrpeUtl) to parse the Version.Windows string:

var

  str1, str2 : string;

begin

  str1 := Crpe1.Version.Windows;

  str2 := Crpe1.GetToken(str1, '/');

  ShowMessage('The Windows platform is: ' + str2 + chr(10) +

    'and the Windows version number is: ' + str1);

end;


Create method

See also

Applies to

Version

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component and does not need to be called in code.


Create method - See also
Related

DLL

Engine

Windows

Clear

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method

See also	Example

Applies to

Version

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Version information from the Report, and stores it in the Version object.  This does not normally need to be called in code, since it is called automatically whenever the Crystal Reports Print Engine is opened.  The component will open the Print Engine whenever required, although it can also be opened manually via the OpenEngine method.


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following example shows the code syntax of the Retrieve function:

Crpe1.Version.Retrieve;

ShowMessage(Crpe1.Version.DLL);


Clear method

See also	Example

Applies to

Version

Declaration

procedure Clear;

Description

The Clear method will reset the three Version properties to their default (empty strings).  This should not normally need to be used, since the Version properties are updated every time the Crystal Reports Print Engine is opened, which is handled internally in the component.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

The following example shows the code syntax of the Clear method:

Crpe1.Version.Clear;

Crpe1.Version.Retrieve;

ShowMessage(Crpe1.Version.DLL);


FileVersion property

See also	Example

Applies to

Version

Declaration

property FileVersion: string;

Description

The FileVersion property is a read-only property that contains the File Version number of the CRPE32.DLL which is currently open.  This is usually formatted as a comma-delimited string, ie.: 6, 0, 1, 135.

While the DLL and Engine properties expose the internal major and minor version numbers, this property shows the full version number string, including the release version (the last number in the string).

FileVersion can be used whenever you build functionality into a Report that may not be available in earlier versions of the Crystal Report Engine and you need to verify the version number first.  This property can also be a handy safeguard for users who have more than one version of the Crystal Report Engine with the older version earlier in the path than the new version.

Note

There is some internal protection built into the VCL which will prevent operation if a CRPE32.DLL earlier than 5.x.x.108 attempts to load.

The SummaryInfo object, the WindowEvents, the WindowCursor object, and most of the WindowButtonBar options (except for Visible), will only work with Crystal Reports 6.0, and the ParamFields object requires the last maintenance release of 5.0: 5.0.x.108.


FileVersion property - See also
Related

DLL

Engine

Major

Minor

Windows

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


FileVersion property - Example
Example

The following example checks to see if the version of the CRPE32.DLL is greater than 5.  If it is, the WindowButtonBar buttons can be made visible/invisible.

if StrToInt(Crpe1.Version.FileVersion[1]) > 5 then

  Crpe1.WindowButtonBar.AllowDrillDown := True;


CopyFrom method

See also	Example

Applies to

Version

Declaration

procedure CopyFrom(Source: TCrpeVersion);

Description

The CopyFrom method copies the Version property values from another TCrpeVersion object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Version property values to a temporary TCrpeVersion object:

var

tempVersion : TCrpeVersion;

begin

tempVersion := TCrpeVersion.Create;

tempVersion.CopyFrom(Crpe1.Version);

{...later, when finished with the temp object...}

tempVersion.Free;

end;


Major property

See also	Example

Applies to

Version

Declaration

property Major: integer;

Description

The Major property is a read-only property that contains the major File Version number of the CRPE32.DLL which is currently open.  This is the first number sequence of the File Version string, ie. for 6, 0, 1, 135, the Major version number would be 6.


Major property - See also
Related

Minor

DLL

Engine

FileVersion

Windows

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Major property - Example
Example

The following example checks to see if the version of the CRPE32.DLL is greater than 5.  If it is, the WindowButtonBar buttons can be made visible/invisible.

if Crpe1.Version.Major > 5 then

  Crpe1.WindowButtonBar.AllowDrillDown := True;


Minor property

See also	Example

Applies to

Version

Declaration

property Minor: integer;

Description

The Minor property is a read-only property that contains the minor File Version number of the CRPE32.DLL which is currently open.  This is the last number sequence of the File Version string, ie. for 6, 0, 1, 135, the Minor version number would be 135.


Minor property - See also
Related

Major

DLL

Engine

FileVersion

Windows

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Minor property - Example
Example

The following example checks the Major and Minor versions to see if the correct DLL is being used:

if (Crpe1.Version.Major = 6) and (Crpe1.Version.Minor = 135) then

  ShowMessage('Get the 151 Maintenance Release!');


WindowSize

See also	Properties & Methods	Example

Declaration

property WindowSize: TCrpeWindowSize;

Type

TCrpeWindowSize = class(TPersistent)

Description

WindowSize contains four properties that determine the position and size of the Crystal Reports runtime Preview Window.

•	The Top and Left properties determine the position of the Window, starting with the top left corner.

•	The Height and Width properties determine the size of the window.

•	The coordinates are in pixels.

•	Use -1 for default Window size and placement.

•	Values less than -1 will generate an error.


WindowSize - See also
Related

WindowButtonBar

WindowState

WindowStyle

WindowZoom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


WindowSize - Properties & Methods
WindowSize:

Properties & Methods

WindowSize	TCrpe Component

Properties

Height

Left

Top

Width

Methods

Clear

CopyFrom

Retrieve

Send

Constructor

Create


WindowSize - Example
Example

The following example displays a Report in a Preview Window.  The window will appear in the upper left corner of the screen and will be 300 pixels high, and 500 pixels wide:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowSize do

begin

  Left := 0;

  Top := 0;

  Height := 300;

  Width := 500;

end;

Crpe1.Execute;


Height property

See also	Example

Applies to

WindowSize

Declaration

property Height: smallint;

Description

The Height property specifies the height of the Preview Window, in pixels.  Use -1 for default.


Height property - See also
Related

Left

Top

Width

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Height property - Example
Example

The following example displays a Report in a Preview Window.  The window will appear in the upper left corner of the screen and will be 300 pixels high, and 500 pixels wide:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowSize do

begin

  Left := 0;

  Top := 0;

  Height := 300;

  Width := 500;

end;

Crpe1.Execute;


Left property

See also	Example

Applies to

WindowSize

Declaration

property Left: smallint;

Description

The Left property specifies the x coordinate of the upper left corner of the Preview Window, in pixels.  Use -1 for default.


Left property - See also
Related

Height

Top

Width

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Left property - Example
Example

The following example displays a Report in a Preview Window.  The window will appear in the upper left corner of the screen and will be 300 pixels high, and 500 pixels wide:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowSize do

begin

  Left := 0;

  Top := 0;

  Height := 300;

  Width := 500;

end;

Crpe1.Execute;


Top property

See also	Example

Applies to

WindowSize

Declaration

property Top: smallint;

Description

The Top property specifies the y coordinate of the upper left corner of the Preview Window, in pixels.  Use -1 for default.


Top property - See also
Related

Height

Left

Width

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Top property - Example
Example

The following example displays a Report in a Preview Window.  The window will appear in the upper left corner of the screen and will be 300 pixels high, and 500 pixels wide:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowSize do

begin

  Left := 0;

  Top := 0;

  Height := 300;

  Width := 500;

end;

Crpe1.Execute;


Width property

See also	Example

Applies to

WindowSize

Declaration

property Width: smallint;

Description

The Width property specifies the width of the Preview Window, in pixels.  Use -1 for default.


Width property - See also
Related

Height

Left

Top

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Width property - Example
Example

The following example displays a Report in a Preview Window.  The window will appear in the upper left corner of the screen and will be 300 pixels high, and 500 pixels wide:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowSize do

begin

  Left := 0;

  Top := 0;

  Height := 300;

  Width := 500;

end;

Crpe1.Execute;


Create method

See also

Applies to

WindowSize

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component and does not need to be called in code.


Create method - See also
Related

Height

Left

Top

Width

Clear

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method

See also	Example

Applies to

WindowSize

Declaration

function Retrieve: boolean;

Description

Retrieve can be used to obtain the size of the currently open Crystal Preview Window.  If there is a Preview Window open when the Retrieve method is called, the WindowSize properties will be updated with the Preview Window size and position.


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code sample runs a Report to Preview Window, then retrieves the size and position of the Window:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.WindowSize.Retrieve;


Clear method

See also	Example

Applies to

WindowSize

Declaration

procedure Clear;

Description

The Clear method clears the WindowSize properties, setting them all to their default values:

Top    := -1;

Left   := -1;

Width  := -1;

Height := -1;

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the WindowSize properties:

Crpe1.WindowSize.Clear;


CopyFrom method

See also	Example

Applies to

WindowSize

Declaration

procedure CopyFrom(Source: TCrpeWindowSize);

Description

The CopyFrom method copies the WindowSize property values from another TCrpeWindowSize object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the WindowSize property values to a temporary TCrpeWindowSize object:

var

tempWindowSize : TCrpeWindowSize;

begin

tempWindowSize := TCrpeWindowSize.Create;

tempWindowSize.CopyFrom(Crpe1.WindowSize);

{...later, when finished with the temp object...}

tempWindowSize.Free;

end;


Send method

See also	Example

Applies to

WindowSize

Declaration

function Send : boolean;

Description

Send can be used to actively change the size and position of the currently open Crystal Preview Window.  The size and position of the Preview Window will be changed to reflect the values of the Top, Left, Width and Height properties.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

The following code sample runs a Report to Preview Window, then changes the size and position of the Window:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.WindowSize.Retrieve;

Crpe1.WindowSize.Top := 5;

Crpe1.WindowSize.Left := 5;

Crpe1.WindowSize.Send;


WindowZoom

See also	Properties & Methods	Example

Declaration

property WindowZoom: TCrpeWindowZoom;

Type

TCrpeWindowZoom = class(TPersistent)

Description

WindowZoom controls the zoom level of the Preview Window when sending a Report to window.

•	The Preview property can be set to one of four pre-defined levels: pwNormal, pwPageWidth, pwWholePage, or pwDefault.

•	The Magnification property can be set to a Zoom percentage from 25 to 400 percent.

•	The two properties are mutually exclusive, that is, assigning a value other than default to one of the properties, will cause the other to be set to default.

•	The WindowZoom properties can be set in code before or after the Execute method.  If they are set after Execute, and the Output property was set toWindow, they will change the zoom level of the current Report window.


WindowZoom - See also
Related

WindowButtonBar

WindowSize

WindowState

WindowStyle

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


WindowZoom - Properties & Methods
WindowZoom:

Properties & Methods

WindowZoom	TCrpe Component

Properties

Magnification

Preview

Methods

Clear

CopyFrom

NextLevel

Send

Constructor

Create


WindowZoom - Example
Example

This example sets the zoom magnification level of the Preview Window to 50 percent:

Crpe1.WindowZoom.Magnification := 50;

This example sets the Preview Window zoom level so that the Report will be sized to the width and height of the window:

Crpe1.WindowZoom.Preview := pwWholePage;


Magnification property

See also	Example

Applies to

WindowZoom

Declaration

property Magnification: TCrZoomMagnification;

Type

TCrZoomMagnification = -1..400;

Description

The Magnification property controls the zoom level of a Report Preview Window.  The acceptable values are:

0,1,2	: Same as the Preview enumerated values (pwNormal, pwPageWidth, pwWholePage)

25 to 400	: Magnification by percentage

-1, 3 to 24	: Default Magnification used (no change)

Note

The ZoomMagnification range goes down to -1 because -1 is used as a standard numeric default value throughout Delphi and throughout the Crystal component.  However, in this case, any value below 25 (except 0,1, or 2) will be counted as default, ie. the property will be ignored.


Magnification property - See also
Related

Preview

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Magnification property - Example
Example

This example sets the zoom magnification level of the Preview Window to 50 percent:

Crpe1.WindowZoom.Magnification := 50;


Preview property

See also	Example

Applies to

WindowZoom

Declaration

property Preview: TCrZoomPreview;

Types

TCrZoomPreview = (pwNormal, pwPageWidth, pwWholePage, pwDefault);

Description

The Preview property sets the zoom level of a Report Preview Window to a pre-defined level:

pwNormal	= Equivalent to 100% magnification.

pwPageWidth	= The Report will be sized to fit the width of the Preview Window.

pwWholePage	= The Report will be sized to fit the width and height of the Preview Window.

pwDefault	= The Preview property is ignored.  The zoom level will be determined by the level the Report was saved with, or the setting of the Magnification property.

The property may be set in code, either before or after the Execute method.  If it is used after Execute, it will immediately act on the currently open Preview Window.


Preview property - See also
Related

Magnification

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Preview property - Example
Example

This example sets the Preview Window zoom level so that the Report will be sized to the width and height of the window:

Crpe1.WindowZoom.Preview := pwWholePage;


Create method

See also

Applies to

WindowZoom

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method

See also	Example

Applies to

WindowZoom

Declaration

function Send: boolean;

Description

The Send method sends the WindowZoom values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the WindowZoom settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.WindowZoom.Send;


Clear method

See also	Example

Applies to

WindowZoom

Declaration

procedure Clear;

Description

This method can be used to set the WindowZoom properties to their default values:

Preview := pwDefault;

Magnification := -1;

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
Related

Magnification

Preview

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

The Clear method sets the Preview and Magnification sub-properties back to their default values:

Crpe1.WindowZoom.Clear;


NextLevel method

See also	Example

Applies to

WindowZoom

Declaration

procedure NextLevel;

Description

The NextLevel method advances the Preview level by one step.

•	If it is currently at pwNormal, it will go to pwPageWidth.

•	If it is at pwPageWidth it will go to pwWholePage.

•	If it is at pwWholePage it will go to pwNormal.

This property can be useful when designing a custom button bar, or custom Form that is to control the Preview Window.


NextLevel method - See also
Related

Preview

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NextLevel method - Example
Example

This code will advance the WindowZoom Preview level by one step:

Crpe1.WindowZoom.NextLevel;


CopyFrom method

See also	Example

Applies to

WindowZoom

Declaration

procedure CopyFrom(Source: TCrpeWindowZoom);

Description

The CopyFrom method copies the WindowZoom property values from another TCrpeWindowZoom object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the WindowZoom property values to a temporary TCrpeWindowZoom object:

var

tempWindowZoom : TCrpeWindowZoom;

begin

tempWindowZoom := TCrpeWindowZoom.Create;

tempWindowZoom.CopyFrom(Crpe1.WindowZoom);

{...later, when finished with the temp object...}

tempWindowZoom.Free;

end;


WindowStyle

See also	Properties & Methods	Example

Declaration

property WindowStyle: TCrpeWindowStyle;

Type

TCrpeWindowStyle = class(TPersistent)

Description

The WindowStyle property contains the properties which determine the Style of the Crystal Preview Window:

BorderStyle	- Window Border Style: sizeable, dialog, etc.

Disabled	- Determines if the Window is enabled or disabled.

SystemMenu	- The Windows menu that appears in the upper left corner of a Window.

MaxButton	- The Maximize button.

MinButton	- The Minimize button.

Title	- The Window Caption.

Depending on what BorderStyle is chosen, certain of the other options may or may not appear, depending on if they apply to that BorderStyle:

BorderStyle	SystemMenu	MaxButton	MinButton	Title

bsNone	n/a	n/a	n/a	n/a

bsSingle	Possible	Possible	Possible	Possible

bsSizeable	Possible	Possible	Possible	Possible

bsDialog	Possible	n/a	n/a	Possible


WindowStyle - See also
Related

WindowButtonBar

WindowSize

WindowState

WindowZoom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


WindowStyle - Properties & Methods
WindowStyle:

Properties & Methods

WindowStyle	TCrpe Component

Properties

BorderStyle

Disabled

MaxButton

MinButton

SystemMenu

Title

Methods

Clear

CopyFrom

Constructor

Create


WindowStyle - Example
Example

This code sample shows how to set the WindowStyle options:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

{Set the WindowStyle options}

with Crpe1.WindowStyle do

begin

  BorderStyle := bsSizeable;

  SystemMenu := True;

  MaxButton := True;

  MinButton := True;

  Title := 'MyReport';

end;

Crpe1.Execute;


BorderStyle property

See also	Example

Applies to

WindowStyle

Declaration

property BorderStyle: TCrFormBorderStyle;

Types

TCrFormBorderStyle = bsNone..bsDialog;

{bsNone, bsSingle, bsSizeable, bsDialog}

Description

The BorderStyle property is of Type: TCrFormBorderStyle, which is a smaller sub-set of Delphi's TFormBorderStyle.  It includes bsNone, bsSingle, bsSizeable, and bsDialog.  Out of these, probably the two most useful are bsSizeable and bsNone, since the first style is best used for running the Preview Window as a stand-alone window, and the second is best used when running the Crystal Window as a child of another Delphi Form.  The default BorderStyle is bsSizeable.


BorderStyle property - See also
Related

SystemMenu

MaxButton

MinButton

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


BorderStyle property - Example
Example

This code sample shows how to set the WindowStyle options:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

{Set the WindowStyle options}

with Crpe1.WindowStyle do

begin

  BorderStyle := bsSizeable;

  SystemMenu := True;

  MaxButton := True;

  MinButton := True;

  Title := 'MyReport';

end;

Crpe1.Execute;


SystemMenu property

See also	Example

Applies to

WindowStyle

Declaration

property SystemMenu: Boolean;

Description

SystemMenu applies to the Windows system menu that appears when the top left corner of a window is clicked, or Alt-SpaceBar is pressed.  This property determines if the system menu is available on the Preview Window or not.  This property is ignored if the BorderStyle is set to bsNone.


SystemMenu property - See also
Related

BorderStyle

MaxButton

MinButton

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SystemMenu property - Example
Example

This code sample shows how to set the WindowStyle options:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

{Set the WindowStyle options}

with Crpe1.WindowStyle do

begin

  BorderStyle := bsSizeable;

  SystemMenu := True;

  MaxButton := True;

  MinButton := True;

  Title := 'MyReport';

end;

Crpe1.Execute;


MaxButton property

See also	Example

Applies to

WindowStyle

Declaration

property MaxButton: Boolean;

Description

MaxButton controls whether the maximize button appears on the Preview Window or not.  If BorderStyle is set to bsNone or bsDialog, this property is ignored because the maximize button is not available for these styles.


MaxButton property - See also
Related

BorderStyle

SystemMenu

MinButton

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


MaxButton property - Example
Example

This code sample shows how to set the WindowStyle options:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

{Set the WindowStyle options}

with Crpe1.WindowStyle do

begin

  BorderStyle := bsSizeable;

  SystemMenu := True;

  MaxButton := True;

  MinButton := True;

  Title := 'MyReport';

end;

Crpe1.Execute;


MinButton property

See also	Example

Applies to

WindowStyle

Declaration

property MinButton: Boolean;

Description

MinButton controls whether the minimize button appears on the Preview Window or not.  If BorderStyle is set to bsNone or bsDialog, this property is ignored because the minimize button is not available for these styles.


MinButton property - See also
Related

BorderStyle

SystemMenu

MaxButton

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


MinButton property - Example
Example

This code sample shows how to set the WindowStyle options:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

{Set the WindowStyle options}

with Crpe1.WindowStyle do

begin

  BorderStyle := bsSizeable;

  SystemMenu := True;

  MaxButton := True;

  MinButton := True;

  Title := 'MyReport';

end;

Crpe1.Execute;


Title property

See also	Example

Applies to

WindowStyle

Declaration

property Title: string;

Description

The Title property contains the string that will appear in the Preview Window Title Bar, which is normally called the window Caption.  If the BorderStyle is set to bsNone, this property will be ignored because windows with no border should not have a caption.

Title is an "active" property.  If it is changed while a Preview Window is open, the Window will be updated immediately.


Title property - See also
Related

BorderStyle

SystemMenu

MaxButton

MinButton

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Title property - Example
Example

This code sample shows how to set the WindowStyle options:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

{Set the WindowStyle options}

with Crpe1.WindowStyle do

begin

  BorderStyle := bsSizeable;

  SystemMenu := True;

  MaxButton := True;

  MinButton := True;

  Title := 'MyReport';

end;

Crpe1.Execute;


Create method

See also

Applies to

WindowStyle

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the WindowStyle object, and does not need to be called in code.


Create method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method

See also	Example

Applies to

WindowStyle

Declaration

procedure Clear;

Description

This method clears the WindowStyle properties by setting them to default:

BorderStyle := bsSizeable;

ControlBox := True;

MaxButton := True;

MinButton := True;

Title := '';

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
Related

BorderStyle

SystemMenu

MaxButton

MinButton

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the WindowStyle properties:

Crpe1.WindowStyle.Clear;


CopyFrom method

See also	Example

Applies to

WindowStyle

Declaration

procedure CopyFrom(Source: TCrpeWindowStyle);

Description

The CopyFrom method copies the WindowStyle property values from another TCrpeWindowStyle object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the WindowStyle property values to a temporary TCrpeWindowStyle object:

var

tempWindowStyle : TCrpeWindowStyle;

begin

tempWindowStyle := TCrpeWindowStyle.Create;

tempWindowStyle.CopyFrom(Crpe1.WindowStyle);

{...later, when finished with the temp object...}

tempWindowStyle.Free;

end;


Disabled property

See also	Example

Applies to

WindowStyle

Declaration

property Disabled: boolean;

Description

The Disabled property can be used to disable and enable the Preview Window.  When the Window is Disabled, it will still be visible, but will not react to keystrokes or mouse clicks.  To hide and show the Preview Window, use the ShowWindow and HideWindow methods of TCrpe.

Disabled can be set either before or after the TCrpe.Execute method is called.  If it is set after Execute, it will act on the open Preview Window.


Disabled property - See also
Related

ShowWindow

HideWindow

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Disabled property - Example
Example

The following example illustrates the use of the Disabled property to deactivate the Preview Window until the Report has finished processing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.WindowStyle.Disabled := True;

Crpe1.Execute;

while Crpe1.Status <> 3 do

  Application.ProcessMessages;

Crpe1.WindowStyle.Disabled := False;


WindowButtonBar

See also	Properties & Methods	Example

Declaration

property WindowButtonBar: TCrpeWindowButtonBar;

Type

TCrpeWindowButtonBar = class(TPersistent)

Description

The WindowButtonBar object contains 15 properties that relate to the Button Bar that appears on the Crystal Reports Preview Window.

•	The Visible property determines if the Button Bar is visible or not and this is the only property that can be used with Crystal Reports 5.0.  The rest of the properties apply to Crystal 6.0 and higher, with the exception of ToolbarTips and DocumentTips, which apply to Crystal 7.0 and higher.

Crystal Reports 6.0 introduced 6 new buttons and one new option to the Button Bar/Preview Window, and provided the capability of specifying which of the buttons should appear.  The new features are:

AllowDrillDown

CancelBtn

CloseBtn

GroupTree

PrintSetup

RefreshBtn

SearchBtn

If the Preview Window is made a Child of a Delphi Form, by attaching the WindowParentHandle property to the Form's Handle then a custom button bar can be designed, and it may be desirable to turn off the Crystal Button Bar by setting the Visible property to False.  Bear in mind, though, that not all the buttons currently on the Crystal Reports Preview Window can be mimicked in code.

The following buttons can be simulated in code:

CancelBtn	-	CancelJob

CloseBtn	-	CloseWindow

ExportBtn	-	ExportWindow

NavigationCtls	-	Pages

PrintBtn	-	PrintOptions.PromptForOptions and PrintWindow

ProgressCtls	-	Records

ZoomCtl	-	WindowZoom

The following buttons cannot be reproduced in code yet:

AllowDrillDown

GroupTree

PrintSetupBtn

RefreshBtn

SearchBtn

The PrintSetupBtn can be partly reproduced by calling a PrinterSetup dialog and then using the GetCurrent method of the Printer object (or just using the ShowPrintDlg method of the Printer object), but this will not affect the current Preview Window or the PrintWindow method, as it will if the PrinterSetup button is called from the Crystal Button Bar.

See also: Creating a Custom Button Bar.


WindowButtonBar - See also
Related

WindowSize

WindowState

WindowStyle

WindowZoom

Creating a Custom Button Bar

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


WindowButtonBar - Properties & Methods
WindowButtonBar:

Properties & Methods

WindowButtonBar	TCrpe Component

Properties

Show/Hide

Visible

Individual Buttons/Controls

AllowDrillDown

CancelBtn

CloseBtn

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ZoomCtl

Hints

DocumentTips

ToolbarTips

Methods

Clear

CopyFrom

Retrieve

Send

Constructor

Create


WindowButtonBar - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, the Cancel button is hidden, and hints will appear on the Toolbar buttons:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  CancelBtn := False;

  ToolbarTips := True;

end;

Crpe1.Execute;


AllowDrillDown property

See also	Example

Applies to

WindowButtonBar

Declaration

property AllowDrillDown: boolean;

Description

AllowDrillDown determines if drill-down capability will be enabled on the Preview Window or not.  This only applies to Crystal 6.0 or higher.


AllowDrillDown property - See also
Related

CancelBtn

CloseBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AllowDrillDown property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Cancel button is hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  CancelBtn := False;

end;

Crpe1.Execute;


CancelBtn property

See also	Example

Applies to

WindowButtonBar

Declaration

property CancelBtn: Boolean;

Description

CancelBtn determines if the Cancel Button will appear on the Preview Window or not.  This only applies to Crystal 6.0 or higher.


CancelBtn property - See also
Related

AllowDrillDown

CloseBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CancelBtn property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Cancel button is hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  CancelBtn := False;

end;

Crpe1.Execute;


CloseBtn property

See also	Example

Applies to

WindowButtonBar

Declaration

property CloseBtn: Boolean;

Description

CloseBtn determines if the Close Button will appear on the Preview Window or not.  This only applies to Crystal 6.0 or higher.


CloseBtn property - See also
Related

AllowDrillDown

CancelBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CloseBtn property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Close button is hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  CloseBtn := False;

end;

Crpe1.Execute;


ExportBtn property

See also	Example

Applies to

WindowButtonBar

Declaration

property ExportBtn: Boolean;

Description

ExportBtn determines if the Export Button will appear on the Preview Window or not.  This only applies to Crystal 6.0 or higher.


ExportBtn property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ExportBtn property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Export button is hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  ExportBtn := False;

end;

Crpe1.Execute;


GroupTree property

See also	Example

Applies to

WindowButtonBar

Declaration

property GroupTree: Boolean;

Description

GroupTree determines if the Group Tree will appear on the Preview Window or not.  This only applies to Crystal 6.0 or higher.  If the Report has been saved with the Group Tree option turned off, it must first be activated using the ReportOptions.CreateGroupTree property (ReportOptions are only available in SCR 7).


GroupTree property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

ExportBtn

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupTree property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Group Tree is visible:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  GroupTree := True;

end;

Crpe1.Execute;


NavigationCtls property

See also	Example

Applies to

WindowButtonBar

Declaration

property NavigationCtls: Boolean;

Description

NavigationCtls determines if the Navigation Controls will appear on the Preview Window or not.  This only applies to Crystal 6.0 or higher.  Navigation Controls are the paging buttons.  The action of these buttons can also be simulated with the Pages object.


NavigationCtls property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

ExportBtn

GroupTree

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NavigationCtls property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Navigation Controls are hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  NavigationCtls := False;

end;

Crpe1.Execute;


PrintBtn property

See also	Example

Applies to

WindowButtonBar

Declaration

property PrintBtn: boolean;

Description

PrintBtn determines if the Print Button will appear on the Preview Window or not.  This only applies to Crystal 6.0 or higher.


PrintBtn property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintBtn property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Print Button is hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  PrintBtn := False;

end;

Crpe1.Execute;


PrintSetupBtn property

See also	Example

Applies to

WindowButtonBar

Declaration

property PrintSetupBtn: boolean;

Description

PrintSetupBtn determines if the Printer Setup Button will appear on the Preview Window or not.  This only applies to Crystal 6.0 or higher.


PrintSetupBtn property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintSetupBtn property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the PrintSetup button is hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  PrintSetupBtn := False;

end;

Crpe1.Execute;


ProgressCtls property

See also	Example

Applies to

WindowButtonBar

Declaration

property ProgressCtls: Boolean;

Description

ProgressCtls determines if the Progress Controls will appear on the Preview Window or not.  This only applies to Crystal 6.0 or higher.  Progress Controls are the numbers that appear when counting the records that have been read, selected, and printed.  These numbers are also available via the Records object.


ProgressCtls property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

RefreshBtn

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ProgressCtls property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Progress  Controls are hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  ProgressCtls := False;

end;

Crpe1.Execute;


RefreshBtn property

See also	Example

Applies to

WindowButtonBar

Declaration

property RefreshBtn: Boolean;

Description

RefreshBtn determines if the Refresh Button will appear on the Preview Window or not.  This only applies to Crystal 6.0 or higher.


RefreshBtn property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


RefreshBtn property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Refresh button is hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  RefreshBtn := False;

end;

Crpe1.Execute;


SearchBtn property

See also	Example

Applies to

WindowButtonBar

Declaration

property SearchBtn: Boolean;

Description

SearchBtn determines if the Search Button will appear on the Preview Window or not.  This only applies to Crystal 6.0 or higher.


SearchBtn property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SearchBtn property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Search button  are hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  SearchBtn := False;

end;

Crpe1.Execute;


Visible property

See also	Example

Applies to

WindowButtonBar

Declaration

property Visible: boolean;

Description

The Visible property determines if the Preview Window Button Bar will be visible or not.  If you are making your own custom button bar, you may want to hide the Crystal button bar.  This can be done by setting Visible to False.

See: Creating a Custom Button Bar


Visible property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Visible property - Example
Example

This code example turns off the Crystal Preview Window button bar:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.WindowButtonBar.Visible := False;

Crpe1.Execute;


ZoomCtl property

See also	Example

Applies to

WindowButtonBar

Declaration

property ZoomCtl: Boolean;

Description

The ZoomCtl property determines if the window control used to set the Zoom Level will be visible on the Preview Window or not.  This only applies to Crystal 6.0 or higher.


ZoomCtl property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

Visible

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ZoomCtl property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and the Zoom Control is hidden:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  ZoomCtl := False;

end;

Crpe1.Execute;


Create method

See also

Applies to

WindowButtonBar

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the WindowButtonBar object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method

See also	Example

Applies to

WindowButtonBar

Declaration

function Retrieve: boolean;

Description

The Retrieve method can be used to obtain the current WindowButtonBar settings from an open Crystal Preview Window.  If there is no open window, the Retrieve method returns False.


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code sample runs a Report to Preview Window, then retrieves the WindowButtonBar settings:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.WindowButtonBar.Retrieve;


Send method

See also	Example

Applies to

WindowButtonBar

Declaration

function Send: boolean;

Description

The Send method sends the WindowButtonBar values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the WindowButtonBar settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.WindowButtonBar.Send;


Clear method

See also	Example

Applies to

WindowButtonBar

Declaration

procedure Clear;

Description

The Clear method sets all the properties associated with the WindowButtonBar object back to their default values:

  Visible := True;

  AllowDrillDown := False;

  CancelBtn := False;

  CloseBtn := False;

  ExportBtn := True;

  GroupTree := False;

  NavigationCtls := True;

  PrintBtn := True;

  PrintSetupBtn := False;

  ProgressCtls := True;

  RefreshBtn := False;

  SearchBtn := False;

  ZoomCtl := True;

These settings are exactly the same as the Crystal Reports 5.0 preview window, which did not have the extra Preview Window buttons that were added in Crystal Reports 6.0, nor did it have the ability to show/hide the various buttons.

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the WindowButtonBar properties:

Crpe1.WindowButtonBar.Clear;


Creating a Custom Button Bar

See also

There are a number of steps required to making your own custom Button Bar on the Preview Window.  In this example, we assume that there is a main project and a main Form called "frmMain", and that the Crystal component is placed on this main Form:

1. Add a new Delphi Form to the Project.  For this example we will call it "frmParentWindow".

2. Add a Panel to frmParentWindow, and Align it to the Top of the Form.  For this example we will call the Panel "pnlBtnBar".

3. Place the desired buttons on the Panel, and write the code for any associated button click events.

4. In the OnResize event of frmParentWindow, type the following code:

procedure TfrmParentWindow.FormResize(Sender: TObject);

var

  WinHandle: hWnd;

begin

  WinHandle := frmMain.Crpe1.ReportWindowHandle;

  SetWindowPos(WinHandle, HWND_TOP, 0, Self.pnlBtnBar.Height, Self.ClientWidth, Self.ClientHeight - Self.pnlBtnBar.Height, SWP_NOZORDER);

end;

5. Go to Project|Options in Delphi, choose the "Forms" tab, and move the frmParentWindow to the "Available Forms" box.

6. Create an event in the main Form to run the Report.  This can be a simple button click.  Type the following code in this event:

begin

  {Create Parent Window}

  frmParentWindow := TfrmParentWindow.Create(Application);

  {Attach Crystal Window to Parent Window}

  frmMain.Crpe1.WindowParentHandle := frmParentWindow.Handle;

  {If minimized, set the Crpe Window to Normal}

  if frmMain.Crpe1.WindowState = wsMinimized then

    frmMain.Crpe1.WindowState := wsNormal;

  {Crystal Window Size Settings}

  frmMain.Crpe1.WindowSize.Top := frmParentWindow.pnlBtnBar.Height;

  frmMain.Crpe1.WindowSize.Left := 0;

  frmMain.Crpe1.WindowSize.Height := frmParentWindow.Height -

     frmParentWindow.pnlBtnBar.Height - 30;

  frmMain.Crpe1.WindowSize.Width := frmParentWindow.Width - 8;

  {Set BorderStyle to bsNone}

  frmMain.Crpe1.WindowStyle.BorderStyle := bsNone;

  {Show the Parent Form}

  frmParentWindow.Show;

  {Set Output and Execute}

  frmMain.Crpe1.Output := toWindow;

  frmMain.Crpe1.Execute;

end;

Note

In setting the Window Size in the above example, I have used some arbitrary allowances (minus 30 on the height, minus 8 on the width) to allow for the window title bar and border width.  This may vary on other systems that have different window settings, and the actual size should probably be retrieved from Windows API calls, but at least this example will give you an idea of how to set up the Parent Window.

7. Simulating the Preview Window buttons - Place buttons on the button bar, and associate their click events with the following examples:

Cancel Button:

Crpe1.CancelJob;

Close Button:

Crpe1.CloseWindow;

Export Button:

Crpe1.ExportWindow(False); {True for Email, False for Diskfile}

Navigation Controls - First Page:

Crpe1.Pages.First;

Navigation Controls - Previous Page:

Crpe1.Pages.Previous;

Navigation Controls - Next Page:

Crpe1.Pages.Next;

Navigation Controls - Last Page:

Crpe1.Pages.Last;

Print Button - with Dialog:

Crpe1.PrintOptions.PromptForOptions := True;

if Crpe1.PrintOptions.Send = cTrue then

  Crpe1.PrintWindow;

Crpe1.PrintOptions.PromptForOptions := False;

Print Button - without Dialog:

Crpe1.PrintWindow;

Progress Controls:

See Creating a User-Defined Progress Dialog

Zoom Control:

Crpe1.WindowZoom.NextLevel;

{or}

Crpe1.WindowZoom.Magnification := n; {n is either 0,1,2 or 25..400}


Custom Button Bar - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method

See also	Example

Applies to

WindowButtonBar

Declaration

procedure CopyFrom(Source: TCrpeWindowButtonBar);

Description

The CopyFrom method copies the WindowButtonBar property values from another TCrpeWindowButtonBar object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the WindowButtonBar property values to a temporary TCrpeWindowButtonBar object:

var

tempWindowButtonBar : TCrpeWindowButtonBar;

begin

tempWindowButtonBar := TCrpeWindowButtonBar.Create;

tempWindowButtonBar.CopyFrom(Crpe1.WindowButtonBar);

{...later, when finished with the temp object...}

tempWindowButtonBar.Free;

end;


ToolbarTips property

See also	Example

Applies to

WindowButtonBar

Declaration

property ToolbarTips: Boolean;

Description

The ToolbarTips property determines if the Preview Window button bar will show hints when the mouse is passed over the controls.

Note

ToolbarTips were made available at runtime with the Seagate Crystal Reports 7.0 Maintenance Release.  If you are using the initial SCR 7 release, you will need to get the maintenance release to use this feature.


ToolbarTips property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

DocumentTips

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ToolbarTips property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and hints will appear on the Button Bar when the mouse passes over the controls:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  ToolbarTips := True;

end;

Crpe1.Execute;


DocumentTips property

See also	Example

Applies to

WindowButtonBar

Declaration

property DocumentTips: Boolean;

Description

The DocumentTips property determines if the Preview Window Report area will show hints when the mouse is passed over the fields on the Report.  This only applies to Crystal 7.0 or higher.

Note

DocumentTips were made available at runtime with the Seagate Crystal Reports 7.0 Maintenance Release.  If you are using the initial SCR 7 release, you will need to get the maintenance release to use this feature.


DocumentTips property - See also
Related

AllowDrillDown

CancelBtn

CloseBtn

ExportBtn

GroupTree

NavigationCtls

PrintBtn

PrintSetupBtn

ProgressCtls

RefreshBtn

SearchBtn

ToolbarTips

Visible

ZoomCtl

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DocumentTips property - Example
Example

This code example sets the WindowButtonBar properties so that Drill-Down is possible, and hints will appear over the fields on the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

with Crpe1.WindowButtonBar do

begin

  Visible := True;

  AllowDrillDown := True;

  DocumentTips := True;

end;

Crpe1.Execute;


Pages

See also	Properties & Methods	Example

Declaration

property Pages: TCrpePages;

Type

TCrpePages = class(TPersistent)

Description

The Pages property is run-time only, and allows the programmer to control paging of the Crystal Preview Window, as well as determining what pages were printed when going to Printer.  The Pages properties only work after the Preview Window is open.  These four properties simulate the use of the paging buttons on the Crystal Button Bar:

First	-	Go to First page of Report.

Next	-	Go to Next page of Report.

Previous	-	Go to Previous page of Report.

Last	-	Go to Last page of Report.

•	The GoToPage property can be used to navigate the Report to a specific page number.

•	The default array property, Item, can also be used to go to a specific page, ie. Pages[2] will cause the Report to go to the second page.

•	The ItemIndex property can also be used to do the same thing, or can be read to determine which page the Report is currently displaying (which is the same as the GetDisplayed method).

There are three other properties: GetDisplayed, GetLatest, and GetStart, which retrieve paging values from the Report.

•	GetDisplayed returns the number of the current page.

•	GetLatest returns the number of the last page that has been previewed thus far.

•	GetStart returns the number of the first page that was displayed.

When going to Preview Window, GetStart will always return 1, but when going to Printer, if the StartPage of the PrintOptions object has been set to something higher than 1, then GetStart will return a number higher than 1.

Tip

When using the Paging properties (Next, Previous, etc.) together with GetDisplayed, be sure to allow time for the Page to finish drawing before checking GetDisplayed:

var

  PageNum : Word;

begin

Crpe1.Pages.Previous;

{Loop until page is finished drawing}

while Crpe1.Status <> 3 do

   Application.ProcessMessages;

PageNum := Crpe1.Pages.GetDisplayed;

end;

See also: Creating a Custom Button Bar


Pages - See also
Related

Records

WindowButtonBar

Creating a Custom Button Bar

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Pages - Properties & Methods
Pages:

Properties & Methods

Pages	TCrpe Component

Properties

Navigation

Item

ItemIndex

Methods

Paging

First

Last

Next

Previous

GoToPage

Page Information

Count

GetDisplayed

GetLatest

GetStart


Pages - Example
Example

This code sample was written to respond to the click of a NextPage button.  Notice how we determine if the Report is on the last page:

var

  pg1, pg2 : integer;

begin

  {Get the Displayed page number}

  pg1 := Crpe1.Pages.GetDisplayed;

  {Show the next page}

  Crpe1.Pages.Next;

  {Loop until page is drawn}

  while Crpe1.Status <> 3 do

    Application.ProcessMessages;

  {Get the Displayed page number}

  pg2 := Crpe1.Pages.GetDisplayed;

  {if Page number stayed the same, it is the Last Page}

  if pg2 = pg1 then

    Label1.Caption := 'Last Page';

end;


Item property

See also	Example

Applies to

Pages

Declaration

property Item[const nIndex: integer]: string;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the Pages object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  Pages[2] is the same as Pages.Item[2].


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

{Set Window to view 3rd page}

Crpe1.Pages.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

{Set Window to view 3rd page}

Crpe1.Pages[2];


ItemIndex property

See also	Example

Applies to

Pages

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to read the current Page (same as GetDisplayed), or set the current Page (same as GoToPage).


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

This code sample illustrates the use of ItemIndex to show and set the page displayed:

var

  pg1: integer;

begin

  {Get the Displayed page number}

  pg1 := Crpe1.Pages.ItemIndex;

  {Show the next page}

  Crpe1.Pages.ItemIndex := pg1 + 1;

end;


Count method

See also	Example

Applies to

Pages

Declaration

function Count: SmallInt;

Description

Count returns the number of Pages in the Report.  This will return 0 until Execute is called.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The following code shows how to get the number of Pages in a Report using the Count property:

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

  ShowMessage(IntToStr(Crpe1.Pages.Count));


GetDisplayed method

See also	Example

Applies to

Pages

Declaration

function GetDisplayed: Word;

Description

GetDisplayed will return the number of the currently active (or previewed) Page.


GetDisplayed method - See also
Related

GetLatest

GetStart

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GetDisplayed method - Example
Example

The following code shows how to get the Displayed Page of a Report:

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

  ShowMessage(IntToStr(Crpe1.Pages.GetDisplayed));


GetLatest method

See also	Example

Applies to

Pages

Declaration

function GetLatest: Word;

Description

GetLatest will return the number of the highest Page that has been built so far.  When going to Preview Window, all the database records are read, but only the Pages required are built (to speed up the display for large Reports).  This is why the Page count display always starts with "Page 1 of 1+".  As the Next Page button is pressed, each page will be built and added to the count, or if the Last Page button is pressed, all the Pages will be built.


GetLatest method - See also
Related

GetDisplayed

GetStart

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GetLatest method - Example
Example

The following code shows how to get the Latest Page of a Report:

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

  ShowMessage(IntToStr(Crpe1.Pages.GetLatest));


GetStart method

See also	Example

Applies to

Pages

Declaration

function GetStart: Word;

Description

GetStart will return the number of the first Page that was built when the Report was run.  When going to Preview Window, this will always be 1, but when going to Printer, if the PrintOptions.StartPage value is greater than 1, GetStart will return that value.


GetStart method - See also
Related

GetDisplayed

GetLatest

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GetStart method - Example
Example

The following code shows how to get the Start Page of a Report.  When going to Printer, this value can be something other than 1:

  Crpe1.ReportName := 'D:\Company.rpt';

  Crpe1.Output := toPrinter;

  Crpe1.PrintOptions.StartPage := 2;

  Crpe1.Execute;

  ShowMessage(IntToStr(Crpe1.Pages.GetStart));


First method

See also	Example

Applies to

Pages

Declaration

procedure First;

Description

The First method causes the Preview Window to go to the first Page of the Report.  This method can be used to simulate the action of the First Page button on the Preview Window.

See also: Creating a Custom Button Bar


First method - See also
Related

GoToPage

Last

Next

Previous

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


First method - Example
Example

The following code shows how to use the First method to go to the first Page of a Report:

  Crpe1.ReportName := 'D:\Company.rpt';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

  Crpe1.Pages.First;


GoToPage method

See also	Example

Applies to

Pages

Declaration

procedure GoToPage(const Value: smallint);

Description

The GoToPage method causes the Preview Window to go to the specified Page of the Report.  Specifying a Page number that is greater than the number of Pages in the current Report will result in an error: "Error 550: Invalid Page Number".

See also: Creating a Custom Button Bar


GoToPage method - See also
Related

First

Last

Next

Previous

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GoToPage method - Example
Example

The following code shows how to use the GoToPage property to set the displayed Page:

  Crpe1.ReportName := 'D:\Company.rpt';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

  Crpe1.Pages.GoToPage(3);


Last method

See also	Example

Applies to

Pages

Declaration

procedure Last;

Description

The Last method causes the Preview Window to go to the last Page of the Report.  This method can be used to simulate the action of the Last Page button on the Preview Window.

See also: Creating a Custom Button Bar


Last method - See also
Related

GoToPage

First

Next

Previous

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Last method - Example
Example

The following code shows how to use the Last method to go to the last Page of a Report:

  Crpe1.ReportName := 'D:\Company.rpt';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

  Crpe1.Pages.Last;


Next method

See also	Example

Applies to

Pages

Declaration

procedure Next;

Description

The Next method causes the Preview Window to go to the next Page of the Report.  This method can be used to simulate the action of the Next Page button on the Preview Window.

See also: Creating a Custom Button Bar


Next method - See also
Related

GoToPage

First

Last

Previous

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Next method - Example
Example

The following code shows how to use the Next method to go to the next Page of a Report:

  Crpe1.ReportName := 'D:\Company.rpt';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

  Crpe1.Pages.Next;


Previous method

See also	Example

Applies to

Pages

Declaration

procedure Previous;

Description

The Previous method causes the Preview Window to go to the previous Page of the Report.  This method can be used to simulate the action of the Previous Page button on the Preview Window.

See also: Creating a Custom Button Bar


Previous method - See also
Related

GoToPage

First

Last

Next

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Previous method - Example
Example

The following code shows how to use the Previous method to go to the previous Page of a Report:

  Crpe1.ReportName := 'D:\Company.rpt';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

  Crpe1.Pages.GoToPage(3);

  Crpe1.Pages.Previous;


Records

See also	Methods

Declaration

property Records: TCrpeRecords;

Type

TCrpeRecords = class(TPersistent)

Description

The Records object contains 3 methods that can be used after the Execute method to determine how many records have been Read, how many have been Selected, and how many have been Printed.

•	These properties are usually used to build a custom dialog or display which counts the Records as the Report is being processed.

See also:

Creating a Custom Button Bar

Creating a User-Defined Progress Dialog


Records - See also
Related

Pages

weOnReadingRecords

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Records - Methods
Records:

Properties & Methods

Records	TCrpe Component

Methods

Printed

Read

Selected


Records - Example
Example

See: Creating a User-Defined Progress Dialog


Printed method

See also	Example

Applies to

Records

Declaration

function Printed: LongInt;

Description

The Printed method returns the number of Records that have been printed as the Report is processing.  When going to Preview Window, only the first Page will be initially drawn, so this method will return the number of Records that have been printed on the first Page only.  As the Pages are navigated, the Printed method will increment to include the new Records that are printed for each Page.


Printed method - See also
Related

Read

Selected

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Printed method - Example
Example

See: Creating a User-Defined Progress Dialog


Read method

See also	Example

Applies to

Records

Declaration

function Read: LongInt;

Description

The Read method returns the number of Records that have been read as the Report is processing.


Read method - See also
Related

Printed

Selected

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Read method - Example
Example

See: Creating a User-Defined Progress Dialog


Selected method

See also	Example

Applies to

Records

Declaration

function Selected: LongInt;

Description

The Selected method returns the number of Records that have been selected as the Report is processing.  The value returned by this method will be dependant on the Selection Formula in the Report.  If there is no Record Selection, Selected will return the same value as Read.


Selected method - See also
Related

Printed

Read

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Selected method - Example
Example

See: Creating a User-Defined Progress Dialog


SummaryInfo

See also	Properties & Methods	Example

Declaration

property SummaryInfo: TCrpeSummaryInfo;

Type

TCrpeSummaryInfo = class(TPersistent)

Description

The SummaryInfo object contains properties that hold Summary Information about the Report.  Summary Information is made up of various fields that describe the Report and are useful for entering more detailed descriptions about the Report than can be specified in the filename itself.

•	Summary Information consists of the Title of the Report, it's Author, Subject, Template, Keywords, and Comments.

•	The Title property holds the same information as the ReportTitle property, or the Report Title field in Crystal Reports Designer.

•	The Comments property holds the same information as the Report Comments field in Crystal Reports Designer.

•	If Summary Information has been entered when the Report was designed, it can be retrieved using the Retrieve method.

Note

You must have Crystal 6.0 or higher to use SummaryInfo.


SummaryInfo - See also
Related

ReportTitle

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SummaryInfo - Properties & Methods
SummaryInfo:

Properties & Methods

SummaryInfo	TCrpe Component

Properties

AppName

Author

Comments

Keywords

Subject

Template

Title

Methods

Clear

CopyFrom method

Retrieve

Send

Constructor

Create

Destructor

Destroy


SummaryInfo - Example
Example

The following code sets two properties of the SummaryInfo object, and then exports the Report to a new Crystal Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SummaryInfo.Title := 'My New Report';

Crpe1.SummaryInfo.Comments.Text := 'A new Report.';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := CrystalReportsRPT

Crpe1.Export.FileName := 'c:\NewReport.rpt';

Crpe1.Execute;


AppName property

See also	Example

Applies to

SummaryInfo

Declaration

property AppName: TCrSummaryString;

Type

TCrSummaryString = string;

Description

AppName is a read-only, run-time only property which indicates which application created the Report.  This property will only have a value if the Retrieve method is called beforehand.  It is limited to 128 characters.


AppName property - See also
Related

Author

Comments

Keywords

Subject

Template

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AppName property - Example
Example

This code sample retrieves the SummaryInfo from a Report and displays the AppName value:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SummaryInfo.Retrieve;

ShowMessage(Crpe1.SummaryInfo.AppName);


Author property

See also	Example

Applies to

SummaryInfo

Declaration

property Author: TCrSummaryString;

Type

TCrSummaryString = string[128];

Description

The Author property specifies the author of the current Report.  It is limited to 128 characters (anything longer than that will be truncated).


Author property - See also
Related

AppName

Comments

Keywords

Subject

Template

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Author property - Example
Example

This code sample retrieves the SummaryInfo from a Report and displays the Author value:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SummaryInfo.Retrieve;

ShowMessage(Crpe1.SummaryInfo.Author);


Comments property

See also	Example

Applies to

SummaryInfo

Declaration

property Comments: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The Comments property specifies any comments for the current Report.  The Comment strings should not be longer than 512 characters, or they will be truncated.


Comments property - See also
Related

AppName

Author

Keywords

Subject

Template

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Comments property - Example
Example

This code sample retrieves the SummaryInfo from a Report and displays the Comments value in a Memo:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SummaryInfo.Retrieve;

Memo1.Lines.Assign(Crpe1.SummaryInfo.Comments);


Keywords property

See also	Example

Applies to

SummaryInfo

Declaration

property Keywords: TCrSummaryString;

Type

TCrSummaryString = string;

Description

The Keywords property specifies the keywords included for the current report.  It is limited to 128 characters (anything longer than that will be truncated).


Keywords property - See also
Related

AppName

Author

Comments

Subject

Template

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Keywords property - Example
Example

This code sample retrieves the SummaryInfo from a Report and displays the Keywords value:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SummaryInfo.Retrieve;

ShowMessage(Crpe1.SummaryInfo.Keywords);


Subject property

See also	Example

Applies to

SummaryInfo

Declaration

property Subject: TCrSummaryString;

Type

TCrSummaryString = string;

Description

The Subject property specifies the subject of the current report.  It is limited to 128 characters (anything longer than that will be truncated).


Subject property - See also
Related

AppName

Author

Comments

Keywords

Template

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Subject property - Example
Example

This code sample retrieves the SummaryInfo from a Report and displays the Subject value:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SummaryInfo.Retrieve;

ShowMessage(Crpe1.SummaryInfo.Subject);


Template property

See also	Example

Applies to

SummaryInfo

Declaration

property Template: TCrSummaryString;

Type

TCrSummaryString = string;

Description

The Template property specifies the ReportTemplate for the current report.  It is limited to 128 characters (anything longer than that will be truncated).


Template property - See also
Related

AppName

Author

Comments

Keywords

Subject

Title

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Template property - Example
Example

This code sample retrieves the SummaryInfo from a Report and displays the Template value:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SummaryInfo.Retrieve;

ShowMessage(Crpe1.SummaryInfo.Template);


Title property

See also	Example

Applies to

SummaryInfo

Declaration

property Title: TCrSummaryString;

Type

TCrSummaryString = string;

Description

The Title property specifies the Report Title of the current Report, and holds the same information as the ReportTitle property, or the Report Title field in Crystal Reports Designer.  It is limited to 128 characters (anything longer than that will be truncated).


Title property - See also
Related

AppName

Author

Comments

Keywords

Subject

Template

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Title property - Example
Example

This code sample retrieves the SummaryInfo from a Report and displays the Title value:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SummaryInfo.Retrieve;

ShowMessage(Crpe1.SummaryInfo.Title);


Create method

See also

Applies to

SummaryInfo

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

SummaryInfo

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method

See also	Example

Applies to

SummaryInfo

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SummaryInfo information from the Report.  SummaryInfo only applies to the main Report, not to Subreports, and is only available with Crystal Reports 6 or higher.  Returns True if the call succeeded.

Note

Attempting to Retrieve SummaryInfo from a Report where the Comments are larger than 512 characters can cause an error in the Print Engine.  This is a known problem (at the time of this writing), and should be addressed in a future release (> 6.0).


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

This code sample retrieves the SummaryInfo from a Report:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SummaryInfo.Retrieve;


Send method

See also	Example

Applies to

SummaryInfo

Declaration

function Send: boolean;

Description

The Send method sends the SummaryInfo values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the SummaryInfo settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SummaryInfo.Send;


Clear method

See also	Example

Applies to

SummaryInfo

Declaration

procedure Clear;

Description

This method can be used to set the SummaryInfo properties to their default values:

AppName := '';

Title := '';

Subject := '';

Author := '';

Keywords := '';

Comments.Clear;

Template := '';

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the SummaryInfo properties:

Crpe1.SummaryInfo.Clear;


CopyFrom method

See also	Example

Applies to

SummaryInfo

Declaration

procedure CopyFrom(Source: TCrpeSummaryInfo);

Description

The CopyFrom method copies the SummaryInfo property values from another TCrpeSummaryInfo object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the SummaryInfo property values to a temporary TCrpeSummaryInfo object:

var

tempSummaryInfo : TCrpeSummaryInfo;

begin

tempSummaryInfo := TCrpeSummaryInfo.Create;

tempSummaryInfo.CopyFrom(Crpe1.SummaryInfo);

{...later, when finished with the temp object...}

tempSummaryInfo.Free;

end;


Margins

See also	Properties & Methods	Example

Declaration

property Margins: TCrpeMargins;

Type

TCrpeMargins = class(TPersistent)

Description

The Margins object contains the four properties: Top, Left, Right, and Bottom.  These control the page margins of the Report.

•	The Retrieve method can be used to get the current margins from the Report.

•	Margin values are defined in Twips (1440 twips = 1 inch).

The main four properties can be assigned any of the following values:

-1	: Use the current Margin value contained in the Report.

-2, 32768	: Use a default Margin value based on the current Printer.

0 to 32767	: Defines a new Margin value.


Margins - See also
Related

Printer

PrintOptions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Margins - Properties & Methods
Margins:

Properties & Methods

Margins	TCrpe Component

Properties

Bottom

Left

Right

Top

Methods

Clear

CopyFrom

Retrieve

Send

Constructor

Create


Margins - Example
Example

The code below obtains the Margins from a Report and makes sure they are set to use Printer defaults:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Margins.Retrieve;

if Crpe1.Margins.Left <> 32768 then

  Crpe1.Margins.Left := 32768;

if Crpe1.Margins.Top <> 32768 then

  Crpe1.Margins.Top := 32768;

if Crpe1.Margins.Right <> 32768 then

  Crpe1.Margins.Right := 32768;

if Crpe1.Margins.Bottom <> 32768 then

  Crpe1.Margins.Bottom := 32768;

Crpe1.Execute;


Bottom property

See also	Example

Applies to

Margins

Declaration

property Bottom: TCrMarginTwips;

Type

TCrMarginTwips = -2..PE_SM_DEFAULT;

Constant

PE_SM_DEFAULT = $8000; {32768 in decimal}

Description

The Bottom property determines the bottom margin of the Report.  It is listed in Twips (1 inch = 1440 twips).  The property can be assigned any number from 0 to 32767, or -1 to use the current margin value as contained in the Report, or -2 (same effect as 32768) for a default margin value based on the current Printer.


Bottom property - See also
Related

Left

Right

Top

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Bottom property - Example
Example

The code below sets the Bottom Margin:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Margins.Bottom := 20;

Crpe1.Execute;


Left property

See also	Example

Applies to

Margins

Declaration

property Left: TCrMarginTwips;

Type

TCrMarginTwips = -2..PE_SM_DEFAULT;

Constant

PE_SM_DEFAULT = $8000; {32768 in decimal}

Description

The Left property determines the left margin of the Report.  It is listed in Twips (1 inch = 1440 twips).  The property can be assigned any number from 0 to 32767, or -1 to use the current margin value as contained in the Report, or -2 (same effect as 32768) for a default margin value based on the current Printer.


Left property - See also
Related

Bottom

Right

Top

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Left property - Example
Example

The code below sets the Left Margin:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Margins.Left := 20;

Crpe1.Execute;


Right property

See also	Example

Applies to

Margins

Declaration

property Right: TCrMarginTwips;

Type

TCrMarginTwips = -2..PE_SM_DEFAULT;

Constant

PE_SM_DEFAULT = $8000; {32768 in decimal}

Description

The Right property determines the right margin of the Report.  It is listed in Twips (1 inch = 1440 twips).  The property can be assigned any number from 0 to 32767, or -1 to use the current margin value as contained in the Report, or -2 (same effect as 32768) for a default margin value based on the current Printer.


Right property - See also
Related

Bottom

Left

Top

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Right property - Example
Example

The code below sets the Right Margin:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Margins.Right := 20;

Crpe1.Execute;


Top property

See also	Example

Applies to

Margins

Declaration

property Top: TCrMarginTwips;

Type

TCrMarginTwips = -2..PE_SM_DEFAULT;

Constant

PE_SM_DEFAULT = $8000; {32768 in decimal}

Description

The Top property determines the top margin of the Report.  It is listed in Twips (1 inch = 1440 twips).  The property can be assigned any number from 0 to 32767, or -1 to use the current margin value as contained in the Report, or -2 (same effect as 32768) for a default margin value based on the current Printer.


Top property - See also
Related

Bottom

Left

Right

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Top property - Example
Example

The code below sets the Top Margin:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Margins.Top := 20;

Crpe1.Execute;


Create method

See also

Applies to

Margins

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method

See also	Example

Applies to

Margins

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Margins information from the Report.  Returns True if the call succeeded.

Note

Since the Margins object also applies to Subreports, the Retrieve method will obtain the Margins for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the Margins settings for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate Margin settings for each Subreport (see Example).


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Margins.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.Margins.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

Margins

Declaration

function Send: boolean;

Description

The Send method sends the Margins values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the Margins settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.Margins.Send;


Clear method

See also	Example

Applies to

Margins

Declaration

procedure Clear;

Description

This method can be used to set the Margins properties to their default values:

Left   := -1;

Right  := -1;

Top    := -1;

Bottom := -1;

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the Margins properties:

Crpe1.Margins.Clear;


CopyFrom method

See also	Example

Applies to

Margins

Declaration

procedure CopyFrom(Source: TCrpeMargins);

Description

The CopyFrom method copies the Margins property values from another TCrpeMargins object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Margins property values to a temporary TCrpeMargins object:

var

tempMargins : TCrpeMargins;

begin

tempMargins := TCrpeMargins.Create;

tempMargins.CopyFrom(Crpe1.Margins);

{...later, when finished with the temp object...}

tempMargins.Free;

end;


PrintDate

See also	Properties & Methods	Example

Declaration

property PrintDate: TCrpePrintDate;

Type

TCrpePrintDate = class(TPersistent)

Description

The PrintDate object contains the three properties that make up the print date: Year, Month, and Day.

•	These properties can be used to set the Print Date of the Report to something other than the current date, so as to generate Reports that appear to have been run a month ago, etc.

•	The Retrieve method can be used to get the current PrintDate from the Report.


PrintDate - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintDate - Properties & Methods
PrintDate:

Properties & Methods

PrintDate	TCrpe Component

Properties

Day

Month

Year

Methods

Clear

CopyFrom

Retrieve

Send


PrintDate - Example
Example

The following sample sets the PrintDate to January 1, 1997:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.PrintDate.Day := 1;

Crpe1.PrintDate.Month := 1;

Crpe1.PrintDate.Year := 1997;

Crpe1.Execute;


Day property

See also	Example

Applies to

PrintDate

Declaration

property Day: Word;

Description

This property sets the Day portion of the PrintDate.  Enter a Day value from 1 to 31.  When setting PrintDate, all three properties (Day, Month, Year) must be greater than 0 for the new PrintDate to take effect.


Day property - See also
Related

Month

Year

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Day property - Example
Example

The following sample sets the PrintDate to January 1, 1997:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.PrintDate.Day := 1;

Crpe1.PrintDate.Month := 1;

Crpe1.PrintDate.Year := 1997;

Crpe1.Execute;


Month property

See also	Example

Applies to

PrintDate

Declaration

property Month: Word;

Description

This property sets the Month portion of the PrintDate.  Enter a Month value from 1 to 12, where January = 1 and December = 12.  When setting PrintDate, all three properties (Day, Month, Year) must be greater than 0 for the new PrintDate to take effect.


Month property - See also
Related

Day

Year

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Month property - Example
Example

The following sample sets the PrintDate to January 1, 1997:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.PrintDate.Day := 1;

Crpe1.PrintDate.Month := 1;

Crpe1.PrintDate.Year := 1997;

Crpe1.Execute;


Year property

See also	Example

Applies to

PrintDate

Declaration

property Year: Word;

Description

This property sets the Year portion of the PrintDate.  Enter the Year as a four-digit number.  When setting PrintDate, all three properties (Day, Month, Year) must be greater than 0 for the new PrintDate to take effect.


Year property - See also
Related

Day

Month

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Year property - Example
Example

The following sample sets the PrintDate to January 1, 1997:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.PrintDate.Day := 1;

Crpe1.PrintDate.Month := 1;

Crpe1.PrintDate.Year := 1997;

Crpe1.Execute;


Retrieve method

See also	Example

Applies to

PrintDate

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the PrintDate information from the Report.  Returns True if the call succeeded.

Note

Since the PrintDate object also applies to Subreports, the Retrieve method will obtain the PrintDate for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the PrintDate settings for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate PrintDate settings for each Subreport.


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Margins.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.Margins.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

PrintDate

Declaration

function Send: boolean;

Description

The Send method sends the PrintDate values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the PrintDate settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.PrintDate.Send;


Clear method

See also	Example

Applies to

PrintDate

Declaration

procedure Clear;

Description

This method can be used to set the PrintDate properties to their default values:

Day   := 0;

Month := 0;

Year  := 0;

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the PrintDate properties:

Crpe1.PrintDate.Clear;


CopyFrom method

See also	Example

Applies to

PrintDate

Declaration

procedure CopyFrom(Source: TCrpePrintDate);

Description

The CopyFrom method copies the PrintDate property values from another TCrpePrintDate object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the PrintDate property values to a temporary TCrpePrintDate object:

var

tempPrintDate : TCrpePrintDate;

begin

tempPrintDate := TCrpePrintDate.Create;

tempPrintDate.CopyFrom(Crpe1.PrintDate);

{...later, when finished with the temp object...}

tempPrintDate.Free;

end;


Email

See also	Properties & Methods	Example

Applies to

Export

Declaration

property Email: TCrpeExportEmail;

Type

TCrpeExportEmail = class(TPersistent)

Description

The Email object encompasses the properties needed to specify an Email destination for Export.  If the Export Destination is EmailViaMapi, then the four properties available are:

CCList

Message

Subject

ToList

If the Destination is EmailViaVIM, then a fifth property is also available:

VIMBCCList

The Clear method can be used to set all the properties back to empty strings.

Notes

When exporting to Email, the FileName property will not apply, but the FileName will be taken from the ReportName.  One exception to this rule is the HTML format, in which a FileName must be specified when exporting to Email, or a Print Engine "999" Error will result.

There currently seems to be a problem exporting to ODBC when the destination is Email.  The Table will be created on the ODBC Data Source, but the Email send will fail.  If you need to export an ODBC table to Email, it will have to be done in two steps:

1. Export the Report to ODBC Table

2. Send the Table to Email in your application code.


Email - See also
Related

Exchange

Export

ODBC

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Email - Properties & Methods
Email:

Properties & Methods

Email	TCrpe Component

Properties

ToList

CCList

VIMBCCList

Subject

Message

Methods

Clear

CopyFrom


Email - Example
Example

Export to Email in HTML format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toEmailViaMapi;

  FileType := HTML3;

  FileName := 'C:\MyReport.htm';

  Email.ToList := 'Maxwell Smart';

  Email.CCList := 'The Chief';

  Email.Subject := 'Chaos';

  Email.Message := 'Would you believe...';

end;

Crpe1.Execute;


CCList property

See also	Example

Applies to

Email

Declaration

property CCList: string;

Description

Specifies the CC list to which you want your Email message sent.  Applies to both MAPI and VIM.

Multiple names must be separated by a semicolon.


CCList property - See also
Related

ToList

VIMBCCList

Subject

Message

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CCList property - Example
Example

Export to Email in HTML format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toEmailViaMapi;

  FileType := HTML3;

  FileName := 'C:\MyReport.htm';

  Email.ToList := 'Maxwell Smart';

  Email.CCList := 'The Chief';

  Email.Subject := 'Chaos';

  Email.Message := 'Would you believe...';

end;

Crpe1.Execute;


Message property

See also	Example

Applies to

Email

Declaration

property Message: string;

Description

Specifies the string you want to appear as the body of your Email Message.  Applies to both MAPI and VIM.


Message property - See also
Related

ToList

CCList

VIMBCCList

Subject

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Message property - Example
Example

Export to Email in HTML format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toEmailViaMapi;

  FileType := HTML3;

  FileName := 'C:\MyReport.htm';

  Email.ToList := 'Maxwell Smart';

  Email.CCList := 'The Chief';

  Email.Subject := 'Chaos';

  Email.Message := 'Would you believe...';

end;

Crpe1.Execute;


Subject property

See also	Example

Applies to

Email

Declaration

property Subject: string;

Description

Specifies the Subject line in your Email message.  Applies to both MAPI and VIM.


Subject property - See also
Related

ToList

CCList

VIMBCCList

Message

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Subject property - Example
Example

Export to Email in HTML format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toEmailViaMapi;

  FileType := HTML3;

  FileName := 'C:\MyReport.htm';

  Email.ToList := 'Maxwell Smart';

  Email.CCList := 'The Chief';

  Email.Subject := 'Chaos';

  Email.Message := 'Would you believe...';

end;

Crpe1.Execute;


ToList property

See also	Example

Applies to

Email

Declaration

property ToList: string;

Description

Specifies the "To" list to which you want your Email message directed.  Applies to both MAPI and VIM.  Multiple names must be separated by a semicolon.


ToList property - See also
Related

CCList

VIMBCCList

Subject

Message

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ToList property - Example
Example

Export to Email in HTML format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toEmailViaMapi;

  FileType := HTML3;

  FileName := 'C:\MyReport.htm';

  Email.ToList := 'Maxwell Smart';

  Email.CCList := 'The Chief';

  Email.Subject := 'Chaos';

  Email.Message := 'Would you believe...';

end;

Crpe1.Execute;


VIMBCCList property

See also	Example

Applies to

Email

Declaration

property VIMBCCList: string;

Description

Specifies the "Blind CC" list to which you want your Email message copied.  Applies to VIM only (cc:Mail), not MAPI.  Multiple names must be separated by a semicolon.


VIMBCCList property - See also
Related

ToList

CCList

Subject

Message

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


VIMBCCList property - Example
Example

Export to Email in HTML format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toEmailViaVIM;

  FileType := HTML3;

  FileName := 'C:\MyReport.htm';

  Email.ToList := 'Maxwell Smart';

  Email.CCList := 'The Chief';

  Email.VIMBCCList := 'Agent99; Heimi';

  Email.Subject := 'Chaos';

  Email.Message := 'Would you believe...';

end;

Crpe1.Execute;


Clear Method

See also	Example

Applies to

Email

Declaration

procedure Clear;

Description

This method can be used to set the Email properties to their default values:

ToList     := '';

CCList     := '';

VIMBCCList := '';

Subject    := '';

Message    := '';

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the Email properties:

Crpe1.Export.Email.Clear;


CopyFrom method

See also	Example

Applies to

Email

Declaration

procedure CopyFrom(Source: TCrpeExportEmail);

Description

The CopyFrom method copies the Email property values from another TCrpeExportEmail object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Email property values to a temporary TCrpeExportEmail object:

var

tempEmail : TCrpeExportEmail;

begin

tempEmail := TCrpeExportEmail.Create;

tempEmail.CopyFrom(Crpe1.Export.Email);

{...later, when finished with the temp object...}

tempEmail.Free;

end;


Exchange

See also	Properties & Methods	Example

Applies to

Export

Declaration

property Exchange: TCrpeExportExchange;

Type

TCrpeExportExchange = class(TPersistent)

Description

The Exchange object encompasses the properties needed to specify an Exchange Folder destination for Export.  The three properties are:  Profile, Folder, and Password.

•	Profile is the Exchange Profile name.

•	Password is the Exchange Password required.

•	Folder is the Exchange Folder string which represents the desired destination.

The "@" sign is used to specify sub-folders for the Folder property:

Crpe1.Export.Exchange.Folder := 'Personal Folders@Inbox';


Exchange - See also
Related

Email

Export

ODBC

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Exchange - Properties & Methods
Exchange:

Properties & Methods

Exchange	TCrpe Component

Properties

Folder

Password

Profile

Methods

Clear

CopyFrom


Exchange - Example
Example

Export to Exchange Folder in PaginatedText format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toMSExchange;

  FileType := PaginatedText;

  LinesPerPage := 25;

  Exchange.Profile := 'Microsoft Outlook';

  Exchange.Folder := 'Personal Folders@Inbox';

  Exchange.Password := 'Agent86';

end;

Crpe1.Execute;


Folder property

See also	Example

Applies to

Exchange

Declaration

property Folder: string;

Description

Specifies the Exchange Folder name when you want to export to Microsoft Exchange Folder.  ExchangeFolder is case-sensitive.  If you enter a value in the wrong case you will receive an error message.  The "@" symbol is used to indicate sub-folder levels: 'Personal Folders@Inbox'.


Folder property - See also
Related

Password

Profile

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Folder property - Example
Example

Export to Exchange Folder in PaginatedText format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toMSExchange;

  FileType := PaginatedText;

  LinesPerPage := 25;

  Exchange.Profile := 'Microsoft Outlook';

  Exchange.Folder := 'Personal Folders@Inbox';

  Exchange.Password := 'Agent86';

end;

Crpe1.Execute;


Password property

See also	Example

Applies to

Exchange

Declaration

property Password: string;

Description

Specified the Exchange Password when you want to export to Microsoft Exchange.


Password property - See also
Related

Folder

Profile

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Password property - Example
Example

Export to Exchange Folder in PaginatedText format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toMSExchange;

  FileType := PaginatedText;

  LinesPerPage := 25;

  Exchange.Profile := 'Microsoft Outlook';

  Exchange.Folder := 'Personal Folders@Inbox';

  Exchange.Password := 'Agent86';

end;

Crpe1.Execute;


Profile property

See also	Example

Applies to

Exchange

Declaration

property Profile: string;

Description

Specifies the Exchange Profile to export a file, when you want to export a Report to Microsoft Exchange.


Profile property - See also
Related

Folder

Password

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Profile property - Example
Example

Export to Exchange Folder in PaginatedText format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toMSExchange;

  FileType := PaginatedText;

  LinesPerPage := 25;

  Exchange.Profile := 'Microsoft Outlook';

  Exchange.Folder := 'Personal Folders@Inbox';

  Exchange.Password := 'Agent86';

end;

Crpe1.Execute;


Clear method

See also	Example

Applies to

Exchange

Declaration

procedure Clear;

Description

This method can be used to set the Exchange properties to their default values:

Folder   := '';

Password := '';

Profile  := '';

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

The following example illustrates the use of the Clear method between exporting a Report to Exchange Folders.  This is not really required for the Exchange object since all the properties must be filled with new values anyway, but it could be required for other objects in the Crystal Reports component in cases where some of the properties are not going to be filled out with new values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toMSExchange;

  FileType := PaginatedText;

  LinesPerPage := 25;

  Exchange.Profile := 'Microsoft Outlook';

  Exchange.Folder := 'Personal Folders@Inbox';

  Exchange.Password := 'Agent86';

end;

Crpe1.Execute;

with Crpe1.Export.Exchange do

begin

  {Clear the Exchange properties}

  Clear;

  {Set the new values}

  Profile := 'Microsoft Outlook';

  Folder := 'Personal Folders@Inbox';

  Password := 'Agent99';

end;

Crpe1.Execute;


CopyFrom method

See also	Example

Applies to

Exchange

Declaration

procedure CopyFrom(Source: TCrpeExportExchange);

Description

The CopyFrom method copies the Exchange property values from another TCrpeExportExchange object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Exchange property values to a temporary TCrpeExportExchange object:

var

tempExchange : TCrpeExportExchange;

begin

tempExchange := TCrpeExportExchange.Create;

tempExchange.CopyFrom(Crpe1.Export.Exchange);

{...later, when finished with the temp object...}

tempExchange.Free;

end;


LotusNotes

See also	Properties & Methods	Example

Applies to

Export

Declaration

property LotusNotes: TCrpeExportLotusNotes;

Type

TCrpeExportLotusNotes = class(TPersistent)

Description

The LotusNotes object encompasses the properties needed to specify a LotusNotes database for Export.  The three properties are:  DBName, FormName, and Comments.

•	DBName is the Database Name.

•	FormName is ???. (Sorry...lacking information here)

•	Comments is ???.  (Sorry...lacking information here)

The Clear method can be used to set all the properties back to their default values (in this case, empty strings).


LotusNotes - See also
Related

Email

Exchange

Export

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LotusNotes - Properties & Methods
LotusNotes:

Properties & Methods

LotusNotes	TCrpe Component

Properties

DBName

FormName

Comments

Methods

Clear

CopyFrom


LotusNotes - Example
Example

Exporting to LotusNotes database in Text format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toLotusNotes;

  FileType := Ascii;

  LotusNotes.DBName := 'DBTest';

  LotusNotes.FormName := 'Form1';

  LotusNotes.Comments := 'Testing...';

end;

Crpe1.Execute;


DBName property

See also	Example

Applies to

LotusNotes

Declaration

property DBName: string;

Description

Specifies the Database Name when exporting a Report to Lotus Notes database.


DBName property - See also
Related

FormName

Comments

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DBName property - Example
Example

Exporting to LotusNotes database in Text format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toLotusNotes;

  FileType := Ascii;

  LotusNotes.DBName := 'DBTest';

  LotusNotes.FormName := 'Form1';

  LotusNotes.Comments := 'Testing...';

end;

Crpe1.Execute;


FormName property

See also	Example

Applies to

LotusNotes

Declaration

property FormName: string;

Description

Sorry, no information available on this property at this time...


FormName property - See also
Related

DBName

Comments

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


FormName property - Example
Example

Exporting to LotusNotes database in Text format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toLotusNotes;

  FileType := Ascii;

  LotusNotes.DBName := 'DBTest';

  LotusNotes.FormName := 'Form1';

  LotusNotes.Comments := 'Testing...';

end;

Crpe1.Execute;


Comments property

See also	Example

Applies to

LotusNotes

Declaration

property Comments: string;

Description

Sorry, no information available on this property at this time...


Comments property - See also
Related

DBName

FormName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Comments property - Example
Example

Exporting to LotusNotes database in Text format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toLotusNotes;

  FileType := Ascii;

  LotusNotes.DBName := 'DBTest';

  LotusNotes.FormName := 'Form1';

  LotusNotes.Comments := 'Testing...';

end;

Crpe1.Execute;


Clear method

See also	Example

Applies to

LotusNotes

Declaration

procedure Clear;

Description

This method can be used to set the LotusNotes properties to their default values:

DBName   := '';

FormName := '';

Comments := '';

It is called automatically if the Clear method is called for the main component, or for the Export class, but may be called in code as needed.


Clear method - See also
Related

DBName

FormName

Comments

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the LotusNotes properties:

Crpe1.Export.LotusNotes.Clear;


CopyFrom method

See also	Example

Applies to

LotusNotes

Declaration

procedure CopyFrom(Source: TCrpeExportLotusNotes);

Description

The CopyFrom method copies the LotusNotes property values from another TCrpeExportLotusNotes object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the LotusNotes property values to a temporary TCrpeExportLotusNotes object:

var

tempLN : TCrpeExportLotusNotes;

begin

tempLN := TCrpeExportLotusNotes.Create;

tempLN.CopyFrom(Crpe1.Export.LotusNotes);

{...later, when finished with the temp object...}

tempLN.Free;

end;


ODBC

See also	Properties & Methods	Example

Applies to

Export

Declaration

property ODBC: TCrpeExportODBC;

Type

TCrpeExportODBC = class(TPersistent)

Description

The ODBC object encompasses the properties needed to specify an ODBC Table destination for Export.  The four properties are:

Source	: Must be a valid ODBC Data Source Name

User	: Must be a valid UserID (if required)

Password	: Must be a valid Password (if required)

Table	: Specifies the name of the Table to be created.  The Table must not already exist or the Export will fail.

•	If the ODBC Data Source is an SQL-type (Oracle, SQLServer, Sybase, etc.), you must have rights to create a Table on the Server.

•	If the ODBC Data Source is of PC-type (Paradox, dBase, FoxPro, etc.), the resulting Table will be created as a file in the directory specified in the ODBC Data Source.  User and Password are not normally required for these types of Data Sources.

•	Some of the PC-type Data Sources (such as dBase) may not be able to create Tables with names longer than 8 characters.  In this case, the Table name you specify will be truncated if it is over 8 characters.

Note

There currently seems to be a problem exporting to ODBC when the destination is Email.  The Table will be created on the ODBC Data Source, but the Email send will fail.  If you need to export an ODBC table to Email, it will have to be done in two steps:

1. Export the Report to ODBC Table

2. Send the Table to Email in your application code.


ODBC - See also
Related

Email

Exchange

Export

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ODBC - Properties & Methods
ODBC:

Properties & Methods

ODBC	TCrpe Component

Properties

Password

Source

Table

User

Methods

Clear

CopyFrom


ODBC - Example
Example

Exporting to File in ODBC-Table format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toFile;

  FileType := ODBCTable;

  ODBC.Source := 'SQLServer';

  ODBC.User := 'Maxwell Smart';

  ODBC.Password := 'Agent86';

  ODBC.Table := 'ReportTable';

end;

Crpe1.Execute;


Password property

See also	Example

Applies to

ODBC

Declaration

property Password: string;

Description

Specifies the Password required to connect to an ODBC Data Source when exporting a Report in ODBC format.

This is only required if the ODBC Data Source that you are exporting to requires a Password (most SQL types do, most PC types don't).


Password property - See also
Related

Source

User

Table

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Password property - Example
Example

Exporting to File in ODBC-Table format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toFile;

  FileType := ODBCTable;

  ODBC.Source := 'SQLServer';

  ODBC.User := 'Maxwell Smart';

  ODBC.Password := 'Agent86';

  ODBC.Table := 'ReportTable';

end;

Crpe1.Execute;


Source property

See also	Example

Applies to

ODBC

Declaration

property Source: string;

Description

Specifies the name of the ODBC Data Source to export to when exporting a Report in ODBC format.


Source property - See also
Related

User

Password

Table

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Source property - Example
Example

Exporting to File in ODBC-Table format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toFile;

  FileType := ODBCTable;

  ODBC.Source := 'SQLServer';

  ODBC.User := 'Maxwell Smart';

  ODBC.Password := 'Agent86';

  ODBC.Table := 'ReportTable';

end;

Crpe1.Execute;


Table property

See also	Example

Applies to

ODBC

Declaration

property Table: string;

Description

Specifies the name of the Table to export to when exporting a Report in ODBC format.


Table property - See also
Related

Source

User

Password

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Table property - Example
Example

Exporting to File in ODBC-Table format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toFile;

  FileType := ODBCTable;

  ODBC.Source := 'SQLServer';

  ODBC.User := 'Maxwell Smart';

  ODBC.Password := 'Agent86';

  ODBC.Table := 'ReportTable';

end;

Crpe1.Execute;


User property

See also	Example

Applies to

ODBC

Declaration

property User: string;

Description

Specifies the UserID required to connect to the ODBC Data Source when exporting a Report in ODBC format.


User property - See also
Related

Source

Password

Table

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


User property - Example
Example

Exporting to File in ODBC-Table format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toFile;

  FileType := ODBCTable;

  ODBC.Source := 'SQLServer';

  ODBC.User := 'Maxwell Smart';

  ODBC.Password := 'Agent86';

  ODBC.Table := 'ReportTable';

end;

Crpe1.Execute;


Clear method

See also	Example

Applies to

ODBC

Declaration

procedure Clear;

Description

This method can be used to set the ODBC properties to their default values:

Source   := '';

User     := '';

Password := '';

Table    := '';

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the ODBC Export properties:

Crpe1.Export.ODBC.Clear;


CopyFrom method

See also	Example

Applies to

ODBC

Declaration

procedure CopyFrom(Source: TCrpeExportODBC);

Description

The CopyFrom method copies the ODBC property values from another TCrpeExportODBC object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the ODBC property values to a temporary TCrpeExportODBC object:

var

tempODBC : TCrpeExportODBC;

begin

tempODBC := TCrpeExportODBC.Create;

tempODBC.CopyFrom(Crpe1.Export.ODBC);

{...later, when finished with the temp object...}

tempODBC.Free;

end;


Export

See also	Properties & Methods	Example

Declaration

property Export: TCrpeExport;

Type

TCrpeExport = class(TPersistent)

Description

The Export object is one of the largest in the Crystal component and contains all the options that apply to exporting a Report to one of the supported Export formats.  In order to have the Export options apply, the Output property of the Crystal component must be set toExport.

•	The Destination property determines if the exported file will go to File, to Email, to Exchange Folder, or to Application.

•	The FileName property applies if going to disk file.

•	The FileType property determines what the export type will be (RTF, Ascii, HTML, ODBC, etc.).

•	The Email object contains the properties that apply if the Destination is set toEmailViaMapi, toEmailViaVIM, or toEmailViaSMI.  When exporting to Email, the FileName property will not apply, but the FileName will be taken from the ReportName.  One exception to this rule is the HTML format, in which a FileName can be specified when exporting to Email.

•	The Exchange object contains the properties that apply if the Destination is set to Exchange.

•	The ODBC object contains the properties that apply if the Destination is set to ODBCTable.

•	The Excel object contains the properties that apply if the FileType is set to ExcelXLS.

•	The CharSepQuote and CharSepSeparator properties apply if the FileType is set to CharacterSeparated.

•	The  LinesPerPage property applies if the FileType is set to PaginatedText.

•	The UseRptDateFmt and UseRptNumberFmt properties apply if the FileType is set to one of the following: Records, TabSeparated, Dif, Csv, or CharacterSeparated.

•	The PromptOnOverwrite property determines if a warning dialog will appear if the file specified in the FileName property already exists (assuming that the Destination is set to go toFile).

•	The PromptForOptions property will cause all the Export settings to be ignored, and will instead prompt the user for the various options.

•	The AppName property applies if the Destination is set to Application.

The Clear property can be used to set the Export object back to it's default values.  These defaults consist of clearing all the string fields, and setting the following properties:

FileType	:= Ascii;

Destination	:= toFile;

UseRptNumberFmt	:= TCRPE_DEFAULT_USERPTNUMBERFMT;

UseRptDateFmt	:= TCRPE_DEFAULT_USERPTDATEFMT;

LinesPerPage	:= TCRPE_DEFAULT_LINESPERPAGE;

ColumnHeadings	:= False;

PromptForOptions	:= False;

PromptOnOverwrite	:= False;

TCRPE_DEFAULT_USERPTNUMBERFMT	= True;

TCRPE_DEFAULT_USERPTDATEFMT	= True;

TCRPE_DEFAULT_LINESPERPAGE	= 60;


Export - See also
Related

Output

Printer

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Export - Properties & Methods
Export:

Properties & Methods

Export	TCrpe Component

Properties

Destination

FileName

FileType

PromptForOptions

PromptOnOverwrite

Destination - Application

AppName

Destination - Email

Email

Destination - Exchange

Exchange

Destination - LotusNotes

LotusNotes

FileType - CharacterSeparated

CharSepQuote

CharSepSeparator

FileType - Excel

Excel

FileType - ODBCTable

ODBC

FileType - PaginatedText

LinesPerPage

FileType - Various Text Formats

UseRptDateFmt

UseRptNumberFmt

Methods

Clear

CopyFrom

Send

Constructor

Create

Destructor

Destroy


Export - Example
Example

Exporting to File in Ascii format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := Ascii;

Crpe1.Export.FileName := 'C:\MyReport.txt';

Crpe1.Execute;

Exporting to File in ODBCTable format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toFile;

  FileType := ODBCTable;

  ODBC.Source := 'SQLServer';

  ODBC.User := 'Maxwell Smart';

  ODBC.Password := 'Agent86';

  ODBC.Table := 'ReportTable';

end;

Crpe1.Execute;

Export to Email in HTML format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toEmailViaMapi;

  FileType := HTML30;

  FileName := 'C:\MyReport.htm';

  Email.ToList := 'Maxwell Smart';

  Email.CCList := 'The Chief'

  Email.Subject := 'Chaos'

  Email.Message := 'Would you believe...';

end;

Crpe1.Execute;

Export to Exchange Folder in PaginatedText format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toMSExchange;

  FileType := PaginatedText;

  LinesPerPage := 25;

  Exchange.Profile := 'Microsoft Outlook';

  Exchange.Folder := 'Personal Folders@Inbox';

  Exchange.Password := 'Agent86';

end;

Crpe1.Execute;


CharSepQuote property

See also	Example

Applies to

Export

Declaration

property CharSepQuote: Char;

Description

The CharSepQuote property holds the value of the string field quote-mark character when exporting to CharacterSeparated format.  This is the character that is used to specify the start and end of an individual string field.  Quotes are not applied to numeric fields.  This property works in conjunction with CharSepSeparator.


CharSepQuote property - See also
Related

CharSepSeparator

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CharSepQuote property - Example
Example

Exporting to File in CharacterSeparated format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := CharacterSeparated;

Crpe1.Export.FileName := 'C:\Company.txt';

{CharSepQoute surrounds string fields}

Crpe1.Export.CharSepQuote := '#';

{CharSepSeparator separates fields}

Crpe1.Export.CharSepSeparator := '+++';

Crpe1.Execute;


CharSepSeparator property

See also	Example

Applies to

Export

Declaration

property CharSepSeparator: string;

Description

The CharSepSeparator property holds the value of the character(s) used to separate one field from another when exporting to CharacterSeparated format.  This works in conjunction with CharSepQuote.


CharSepSeparator property - See also
Related

CharSepQuote

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CharSepSeparator property - Example
Example

Exporting to File in CharacterSeparated format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := CharacterSeparated;

Crpe1.Export.FileName := 'C:\MyReport.txt';

{CharSepQoute surrounds string fields}

Crpe1.Export.CharSepQuote := '#';

{CharSepSeparator separates fields}

Crpe1.Export.CharSepSeparator := '+++';

Crpe1.Execute;


Destination property

See also	Example

Applies to

Export

Declaration

property Destination: TCrExportDestination;

Type

TCrExportDestination = (toFile, toEmailViaMapi, toEmailViaVIM, toEmailViaSMI, toMSExchange, toLotusNotes, toApplication);

Description

The Destination property determines what kind of Export destination will be used when a Report is exported (ie. when Output is set toExport).  There are seven options:

toFile	- To a Disk File.  FileName must be specified if PromptForOptions is False.

toEmailViaMapi	- To an email message on MS Exchange, MS Outlook, etc.

toEmailViaVIM	- To an email message on Lotus Notes mail, etc.

toEmailViaSMI	- To an email message on SMI mail, etc.

toMSExchange	- To an email message in an MS Exchange Folder.

toLotusNotes	- To a Lotus Notes database.

toApplication	- To an Application, either by file extension association, or specified in AppName.


Destination property - See also
Related

FileType

Email

Exchange

ODBC

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destination property - Example
Example

Exporting to File in ODBCTable format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toFile;

  FileType := ODBCTable;

  ODBC.Source := 'SQLServer';

  ODBC.User := 'Maxwell Smart';

  ODBC.Password := 'Agent86';

  ODBC.Table := 'ReportTable';

end;

Crpe1.Execute;

Export to Email in HTML format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toEmailViaMapi;

  FileType := HTML3;

  FileName := 'c:\MyReport.htm';

  Email.ToList := 'Maxwell Smart';

  Email.CCList := 'The Chief'

  Email.Subject := 'Chaos'

  Email.Message := 'Would you believe...';

end;

Crpe1.Execute;

Export to Exchange Folder in PaginatedText format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toMSExchange;

  FileType := PaginatedText;

  LinesPerPage := 25;

  Exchange.Profile := 'Microsoft Outlook';

  Exchange.Folder := 'Personal Folders@Inbox';

  Exchange.Password := 'Agent86';

end;

Crpe1.Execute;


Email - see 1100


Exchange - see 1200


Excel - see 6000
see 6000


FileName property

See also	Example

Applies to

Export

Declaration

property FileName: TCrExportFileName;

Type

TCrExportFileName = string[255];

Description

FileName holds the name (and path) of the file that will be created when exporting a Report.  This property only applies when the Export Destination is set toFile, except in the case of HTML, where the FileName can be used even when going to Email or Exchange.


FileName property - See also
Related

FileType

PromptForOptions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


FileName property - Example
Example

Exporting to File in Ascii format:

Crpe1.ReportName := 'C:\C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := Ascii;

Crpe1.Export.FileName := 'C:\Company.txt';

Crpe1.Execute;


FileType property

See also	Example

Applies to

Export

Declaration

property FileType: TCrExportType;

Type

TCrExportType = (Records, TabSeparated, Ascii, Dif, Csv, CharacterSeparated, TabSeparatedText, CrystalReportRPT, LotusWK1, LotusWK3, LotusWKS, RTF, WordForWindows, ExcelXLS, HTML30, HTML32ext, HTML32std, ODBCTable, PaginatedText, ReportDefinition);

Description

The FileType property determines what kind of Export format will be used when a Report is exported (ie. when Output is set toExport).  WordPerfect, WordForDOS, and QuattroPro are only available in 16-bit, and are not included in the 32-bit version of the component.

Records	- Record style (columns of values).  Does not use commas or separators. Outputs every record with a fixed field width.  Applicable options: UseRptDateFmt, UseRptNumberFmt.

TabSeparated	- Tab separated values. Presents data in tabular form. Encloses alphanumeric field data in quotes and separates fields with tabs.  Applicable options: UseRptDateFmt, UseRptNumberFmt.

Ascii	- Text style. Saves the data in ASCII text format with all values separated by spaces. This style looks most like the printed page.

Dif	- Saves the data in data interchange format. This format is often used for the transfer of data between different spreadsheet programs.  Applicable options: UseRptDateFmt, UseRptNumberFmt.

Csv	- Comma separated values. Encloses alphanumeric field data in quotes and separates fields with commas.  Applicable options: UseRptDateFmt, UseRptNumberFmt.

CharacterSeparated	- Saves the data as character separated values in ASCII text format. All values are separated by a character or characters specified by CharSepSeparator and CharSepQuote properties.  Applicable options: UseRptDateFmt, UseRptNumberFmt, CharSepQuote, CharSepSeparator.

TabSeparatedText	- Saves the data in ASCII text format with all values separated by tabs.

CrystalReportRPT	- Standard Seagate Crystal Reports format is used.  Most often used for sending the Report to another user via e-mail.

LotusWK1	- Exports the Report as a Lotus 1-2-3 WK1 format worksheet.

LotusWK3	- Exports the Report as a Lotus 1-2-3 WK3 format worksheet.

LotusWKS	- Exports the Report as a Lotus 1-2-3 WKS format worksheet.

RTF	- Saves the data in Rich Text Format.

WordForWindows	- Uses the Microsoft Word for Windows format to save the data in the Report.

ExcelXLS	- Exports the Report to Excel format.  The Excel sub-class further defines which type of Excel file to export.  Available formats range from Excel 2 to Excel 8, with or without Extended options.

HTML30	- Uses HTML 3 format to save the data in the Report.  Applicable options: FileName.

HTML32ext	- Uses the Internet Explorer version of HTML to save the data in the Report.  Applicable options: FileName.

HTML32std	- Uses the Netscape version of HTML to save the data in the Report.  Applicable options: FileName.

ODBCTable	- Exports to a database format corresponding to a specifed ODBC Data Source.  Applicable options (in ODBC sub-class):  Source, User, Password, Table.

PaginatedText	- Exports the Report to Text with Page Headers/Footers.  Applicable options: LinesPerPage

ReportDefinition	- Exports a text file of descriptive details about the Report.  Useful for cataloging Report design information.


FileType property - See also
Related

FileName

PromptForOptions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


FileType property - Example
Example

Exporting to File in Ascii format:

Crpe1.ReportName := 'C:\Report.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := Ascii;

Crpe1.Export.FileName := 'C:\Report.txt';

Crpe1.Execute;


LinesPerPage property

See also	Example

Applies to

Export

Declaration

property LinesPerPage: Word;

Description

LinesPerPage is an option that applies when PaginatedText is chosen as the Export FileType.  It indicates the number of lines to be printed before the page break.  The default is 60 lines.  If PromptForOptions is True, the user will be prompted for the LinesPerPage value.


LinesPerPage property - See also
Related

PromptForOptions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LinesPerPage property - Example
Example

Export to Exchange Folder in PaginatedText format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

with Crpe1.Export do

begin

  Destination := toMSExchange;

  FileType := PaginatedText;

  LinesPerPage := 25;

  Exchange.Profile := 'Microsoft Outlook';

  Exchange.Folder := 'Personal Folders@Inbox';

  Exchange.Password := 'Agent86';

end;

Crpe1.Execute;


ODBC - see 1300


PromptForOptions property

See also	Example

Applies to

Export

Declaration

property PromptForOptions: boolean;

Description

PromptForOptions determines if the Crystal Reports Print Engine will use the Export Options specified in the VCL properties, or if it will prompt the user for those values.  The prompt dialogs are the same as those seen when the Export button is pressed in the Crystal Reports runtime Preview Window, of which the following are samples:

Note

The VCL Export property settings will not affect the default state of the properties in the Print Engine prompt dialogs.


PromptForOptions property - See also
Related

PromptOnOverwrite

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PromptForOptions property - Example
Example

The following code will export a Report and prompt the user for the values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.PromptForOptions := True;

Crpe1.Execute;


PromptOnOverwrite property

See also	Example

Applies to

Export

Declaration

property PromptOnOverwrite: boolean;

Description

PromptOnOverwrite can be used to warn the user if the file that is being exported to already exists.  It is only active if the Destination is toFile.  If PromptOnOverwrite is True, and the file specified in FileName already exists, the following dialog will appear:


PromptOnOverwrite property - See also
Related

PromptForOptions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PromptOnOverwrite property - Example
Example

The following code will export a Report to file, and prompt the user if the file exists already:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := Ascii;

Crpe1.Export.FileName := 'C:\Company.txt';

Crpe1.Export.PromptOnOverwrite := True;

Crpe1.Execute;


UseRptDateFmt property

See also	Example

Applies to

Export

Declaration

property UseRptDateFmt: Boolean;

Description

When exporting a Report, the UseRptDateFmt property indicates whether or not the dates should be exported in the same date format (MDY, DMY, etc.) that is used in the Report or instead optimize the dates for the file format that has been selected.  This property applies only when FileType is set to one of the following:

Records

TabSeparated

Dif

Csv

CharacterSeparated

By default, the UseRptDateFmt property is set to True.


UseRptDateFmt property - See also
Related

UseRptNumberFmt

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


UseRptDateFmt property - Example
Example

The following code shows how to export to File in DIF format.  The Number and Date formats will be optimized for the file format, regardless of how they are formatted in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := Dif;

Crpe1.Export.FileName := 'C:\Company.dif';

Crpe1.Export.UseRptDateFmt := False;

Crpe1.Export.UseRptNumberFmt := False;

Crpe1.Execute;


UseRptNumberFmt property

See also	Example

Applies to

Export

Declaration

property UseRptNumberFmt: Boolean;

Description

When exporting a Report, UseRptNumberFmt indicates whether or not the numbers in the exported file will retain the same format (decimal places, negatives, etc.) used in the Report, or instead optimize the numbers for the file format that has been selected.  This property only applies when PrintFileType is set one of the following types:

Records

TabSeparated

Dif

Csv

CharacterSeparated

By default, the UseRptNumberFmt property is set to True.


UseRptNumberFmt property - See also
Related

UseRptDateFmt

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


UseRptNumberFmt property - Example
Example

The following code shows how to export to File in DIF format.  The Number and Date formats will be optimized for the file format, regardless of how they are formatted in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := Dif;

Crpe1.Export.FileName := 'C:\Company.dif';

Crpe1.Export.UseRptDateFmt := False;

Crpe1.Export.UseRptNumberFmt := False;

Crpe1.Execute;


Create method

See also

Applies to

Export

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Export object, and does not need to be called in code.


Create method - See also
Related

Destroy

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

Export

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
Related

Create

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method

See also	Example

Applies to

Export

Declaration

function Send: boolean;

Description

The Send method sends the Export values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the Export settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.Export.Send;


Clear method

See also	Example

Applies to

Export

Declaration

procedure Clear;

Description

This method can be used to set the Export properties back to their default values.  These defaults consist of clearing all the string fields, and setting the following properties:

FileName          := '';

FileType          := Ascii;

Destination       := toFile;

CharSepQuote      := ' ';

CharSepSeparator  := '';

UseRptNumberFmt   := TCRPE_DEFAULT_USERPTNUMBERFMT; {True}

UseRptDateFmt     := TCRPE_DEFAULT_USERPTDATEFMT;   {True}

LinesPerPage      := TCRPE_DEFAULT_LINESPERPAGE;    {60}

ColumnHeadings    := False;

PromptForOptions  := False;

PromptOnOverwrite := False;

Email.Clear;

Exchange.Clear;

ODBC.Clear;

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the Export properties:

Crpe1.Export.Clear;


CopyFrom method

See also	Example

Applies to

Export

Declaration

procedure CopyFrom(Source: TCrpeExport);

Description

The CopyFrom method copies the Export property values from another TCrpeExport object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Export property values to a temporary TCrpeExport object:

var

tempExport : TCrpeExport;

begin

tempExport := TCrpeExport.Create;

tempExport.CopyFrom(Crpe1.Export);

{...later, when finished with the temp object...}

tempExport.Free;

end;


AppName property

See also	Example

Applies to

Export

Declaration

property AppName: TCrExportAppName;

Type

TCrExportAppName = string;

Description

When the Destination property is set "toApplication", the Report will be exported in one of two ways:

1. If the AppName property has a value assigned to it, the Report will be exported to the FileName specified, and then the VCL will attempt to open this exported file with the application specified in the AppName property.

2. If the AppName property is blank, the Report will be exported to a temporary file, and the Print Engine will attempt to launch the temporary file using the application associated with the filename extension in the Windows environment.


AppName property - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AppName property - Example
Example

The following example exports a Report to a defined application:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toApplication;

Crpe1.Export.FileType := Dif;

Crpe1.Export.FileName := 'C:\Company.dif';

Crpe1.Export.AppName := 'C:\Windows\Notepad.exe';

Crpe1.Execute;

The following example exports a Report to application using the Application with the associated extension in the Windows environment (if there is one):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toApplication;

Crpe1.Export.FileType := Dif;

Crpe1.Export.FileName := 'C:\Company.dif';

Crpe1.Export.AppName := '';

Crpe1.Execute;


Printer

See also	Properties & Methods	Example

Declaration

property Printer: TCrpePrinter;

Type

TCrpePrinter = class(TPersistent)

Description

The Printer object contains all of the properties that relate to setting the Printer to be used for printing the Report.

•	The Name property takes the name of the Printer that is to be selected for the Report.

•	The Driver property takes the Printer Driver associated with that printer.

•	The Port property takes the Printer Port associated with that printer

•	The Mode property takes the Handle to the DevMode pointer for that printer.

•	The PMode property (which is a pointer to the DevMode, rather than a handle) gives direct access to the DevMode structure, which can be used to manipulate other printer-related settings.  See DevMode for more info on the members of the DevMode structure.  Mode and PMode are both updated if either one is changed.

•	The Retrieve method can be used to get the Printer and it's settings from the Report and automatically fill the Name, Driver, Port, and Mode properties with the values.

Traditionally we required all four of those properties to have values before the Printer could be changed.  This is no longer necessary.  The only property that actually needs to be set now is the Name property, which can be set directly:

Crpe1.Printer.Name := 'HP Laserjet 4';

or from the Printers object in Delphi:

Crpe1.Printer.Name := Printer.Printers[2];

Alternatively, the GetCurrent method can be called to retrieve the currently selected printer.  If GetCurrent is used after the PrintDialog is called, it will pick up the selected Printer and automatically fill the Name,  Driver, Port, Mode, and PMode properties.

•	The Orientation property controls the orientation of the Report, and can be set to orDefault, orPortrait, or orLandscape.

•	The PreserveRptSettings set contains three properties that can be used to make sure certain settings are preserved from the Report when the Printer is changed:  prOrientation, prPaperSize, prPaperSource (bin).  If you desire the Orientation to be preserved as it was when the Report was designed, include the prOrientation value as part of the PreserveRptSettings set.  Likewise with the other two set properties.

•	The ShowDialog property replaces the previous UserPrinterSetup property.  If ShowDialog is true, a PrintDialog is displayed when the Send method is called.  This normally happens within the component's Execute method; it is not normally necessary to call the Send method in code.

•	Another way of invoking the PrintDialog at any time (not only when Send or Execute is called), is to use the ShowPrintDlg method.

•	The Clear method can be used to clear the string properties of the Printer object, and to set the other properties to default.


Printer - See also
Related

PrintOptions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Printer - Properties & Methods
Printer:

Properties & Methods

Printer	TCrpe Component

Properties

Printer Description

Name

Driver

Port

DevMode

Mode

PMode

Options

Orientation

PreserveRptSettings

ShowDialog

Methods

Clear

CopyFrom

Retrieve

Send

ShowPrintDlg

Get/Set Current Printer

GetCurrent

SetCurrent

Constructor

Create


Printer - Example
Example

The following code example illustrates how to use some of the Printer object properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

with Crpe1.Printer do

begin

  {Set Name to 3rd Printer in Printers list}

  Name := Printer.Printers[2];

  {Set Orientation to Landscape}

  Orientation := orLandscape;

  {Preserve PaperSize as set in Report}

  PreserveRptSettings := [prPaperSize];

  {Do not show the PrintDialog on Execute}

  ShowDialog := False;

end;

Crpe1.Execute;


Driver property

See also	Example

Applies to

Printer

Declaration

property Driver: TCrPrinterName;

Type

TCrPrinterName = string[80];

Description

The Driver property contains the Driver name of the Printer.

Traditionally, the Crystal VCL used to require the Name, Driver, Port and Mode properties to be set before it would change the Printer for a Report.  With the new Crystal component, however, this is not required.  The only property that needs to be specified is the Name.  The component will automatically fill in the other values (if the Printer Name is valid), when the component's Execute method is called.

If the Retrieve method is used, the Driver property will contain the Driver name for the Printer that was specified in the Report (or the default printer if the Printer specified in the Report is not valid).  Alternatively, the GetCurrent method can be called right after showing Delphi's PrintDialog, and it will also fill the Printer properties with values corresponding to the selected Printer.


Driver property - See also
Related

Name

Driver

Port

Mode

PMode

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Driver property - Example
Example

This code uses the Printer properties to change Printers to one selected via the Print Dialog.  It also makes sure that the Orientation defined in the Report is preserved.

procedure RunReport;

var

  lpPrinter, lpDriver, lpPort : pChar;

  hMode                       : THandle;

  pMode                       : PDevMode;

  nOrientation                : integer;

begin

  {Set ReportName}

  Crpe1.ReportName := 'C:\Company.rpt';

  {Get Printer settings from Report}

  Crpe1.Printer.Retrieve;

  {Check the Orientation}

  hMode := Crpe1.Printer.Mode;

  pMode := GlobalLock(hMode);

  case pMode^.dmOrientation of

    DMORIENT_PORTRAIT  : nOrientation := 0;

    DMORIENT_LANDSCAPE : nOrientation := 1;

  end;

  GlobalUnlock(hMode);

  {Allocate memory for Printer property variables}

  try

    lpPrinter := StrAlloc(255);

    lpDriver := StrAlloc(255);

    lpPort := StrAlloc(255);

  except

    if lpPrinter <> nil then

      StrDispose(lpPrinter);

    if lpDriver <> nil then

      StrDispose(lpDriver);

    if lpPort <> nil then

      StrDispose(lpPort);

    Exit;

  end;

  {Show the PrintDialog}

  if PrintDialog1.Execute then  {if OK was clicked}

  begin

    {Get Selected Printer; could also use Crpe1.SelectPrinter}

    Printer.GetPrinter(lpPrinter, lpDriver, lpPort, hMode);

    {Set PrinterName}

    Crpe1.Printer.Name := StrPas(lpPrinter);

    {Set PrinterDriver: Check for Null - Win95 32-bit problem}

    if Length(StrPas(lpDriver)) <> 0 then

      Crpe1.Printer.Driver := StrPas(lpDriver)

    else

      Crpe1.Printer.Driver := StrPas(lpPrinter);

    {Set PrinterPort}

    Crpe1.Printer.Port := StrPas(lpPort);

    {Set PrinterMode}

    Crpe1.Printer.Mode := hMode;

    {Make sure the Orientation remains as in Report}

    pMode := GlobalLock(hMode);

    case nOrientation of

      0: pMode^.dmOrientation := DMORIENT_PORTRAIT;

      1: pMode^.dmOrientation := DMORIENT_LANDSCAPE;

    end;

    GlobalUnlock(hMode);

    {Run the Report}

    Crpe1.Execute;

  end;

  StrDispose(lpPort);

  StrDispose(lpDriver);

  StrDispose(lpPrinter);

end;

The above code can be greatly simplified by using some of the other Printer object methods & properties:

procedure RunReport;

begin

  {Set ReportName}

  Crpe1.ReportName := 'C:\test.rpt';

  {Preserve Orientation from Report}

  Crpe1.Printer.PreserveRptSettings[prOrientation];

  {Prompt for Printer at Execute}

  Crpe1.Printer.ShowDialog := True;

  {Run the Report}

  Crpe1.Execute;

end;


Mode property

See also	Example

Applies to

Printer

Declaration

property Mode: integer;

Description

The Mode property specifies a handle to the DevMode structure associated with a certain Printer.  This handle is normally obtained via Delphi's "Printer.GetPrinter" method.  Not that it is no longer necessary to fill in a value for this property, since the Crystal component will obtain this information internally provided a valid value is specified in the Name property.

Traditionally, the Crystal VCL used to require the Name, Driver, Port and Mode properties to be set before it would change the Printer for a Report.  With the new Crystal component, however, this is not required.  The only property that needs to be specified is the Name.  The component will automatically fill in the other values (if the Printer Name is valid), when the component's Execute method is called.

If the Retrieve method is used, the Mode property will contain the Mode value for the Printer that was specified in the Report (or the default printer if the Printer specified in the Report is not valid).  Alternatively, the GetCurrent method can be called right after showing Delphi's PrintDialog, and it will also fill the Printer properties with values corresponding to the selected Printer.


Mode property - See also
Related

DevMode Structure

PMode

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Mode property - Example
Example

The following example shows how to use the Mode property to check DevMode settings for the Printer properties saved with the Report (Orientation in this case).  Note that PMode could be used instead, which would eliminate the need for GlobalLock/GlobalUnlock:

var

  hMode        : THandle;

  pMode        : PDevMode;

  nOrientation : integer;

begin

  {Set ReportName}

  Crpe1.ReportName := 'C:\Company.rpt';

  {Get Printer settings from Report}

  Crpe1.Printer.Retrieve;

  {Check the Orientation}

  hMode := Crpe1.Printer.Mode;

  pMode := GlobalLock(hMode);

  case pMode^.dmOrientation of

    DMORIENT_PORTRAIT  : nOrientation := 0;

    DMORIENT_LANDSCAPE : nOrientation := 1;

  end;

  GlobalUnlock(hMode);

end;


Name property

See also	Example

Applies to

Printer

Declaration

property Name: TCrPrinterName;

Type

TCrPrinterName = string[80];

Description

The Name property contains the Printer name of the Printer.

Traditionally, the Crystal VCL used to require the Name, Driver, Port and Mode properties to be set before it would change the Printer for a Report.  With the new Crystal component, however, this is not required.  The only property that needs to be specified is the Name.  The component will automatically fill in the other values (if the Printer Name is valid), when the component's Execute method is called.

If the Retrieve method is used, the Name property will contain the Printer name for the Printer that was specified in the Report (or the default printer if the Printer specified in the Report is not valid).  Alternatively, the GetCurrent method can be called right after showing Delphi's PrintDialog, and it will also fill the Printer properties with values corresponding to the selected Printer.

Additionally, the Name can be specified directly from the Delphi Printers array (you will need to add the Printers unit to the Uses clause before you can use the Printers array):

  Crpe1.Printer.Name := Printer.Printers[2];


Name property - See also
Related

Driver

Port

PMode

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Name property - Example
Example

To change Printers, only the Name property needs to be set (although it will not cause any problems if Driver, Port and Mode properties are set as well).  The rest will be retrieved within the VCL:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Printer.Name := 'HP Laserjet 4';

Crpe1.Execute;

This code uses the Printer properties to change Printers to one selected via the Print Dialog.  It also makes sure that the Orientation defined in the Report is preserved.

procedure RunReport;

var

  lpPrinter, lpDriver, lpPort : pChar;

  hMode                       : THandle;

  pMode                       : PDevMode;

  nOrientation                : integer;

begin

  {Set ReportName}

  Crpe1.ReportName := 'C:\Company.rpt';

  {Get Printer settings from Report}

  Crpe1.Printer.Retrieve;

  {Check the Orientation}

  hMode := Crpe1.Printer.Mode;

  pMode := GlobalLock(hMode);

  case pMode^.dmOrientation of

    DMORIENT_PORTRAIT  : nOrientation := 0;

    DMORIENT_LANDSCAPE : nOrientation := 1;

  end;

  GlobalUnlock(hMode);

  {Allocate memory for Printer property variables}

  try

    lpPrinter := StrAlloc(255);

    lpDriver := StrAlloc(255);

    lpPort := StrAlloc(255);

  except

    if lpPrinter <> nil then

      StrDispose(lpPrinter);

    if lpDriver <> nil then

      StrDispose(lpDriver);

    if lpPort <> nil then

      StrDispose(lpPort);

    Exit;

  end;

  {Show the PrintDialog}

  if PrintDialog1.Execute then  {if OK was clicked}

  begin

    {Get Selected Printer; could also use Crpe1.SelectPrinter}

    Printer.GetPrinter(lpPrinter, lpDriver, lpPort, hMode);

    {Set PrinterName}

    Crpe1.Printer.Name := StrPas(lpPrinter);

    {Set PrinterDriver: Check for Null - Win95 32-bit problem}

    if Length(StrPas(lpDriver)) <> 0 then

      Crpe1.Printer.Driver := StrPas(lpDriver)

    else

      Crpe1.Printer.Driver := StrPas(lpPrinter);

    {Set PrinterPort}

    Crpe1.Printer.Port := StrPas(lpPort);

    {Set PrinterMode}

    Crpe1.Printer.Mode := hMode;

    {Make sure the Orientation remains as in Report}

    pMode := GlobalLock(hMode);

    case nOrientation of

      0: pMode^.dmOrientation := DMORIENT_PORTRAIT;

      1: pMode^.dmOrientation := DMORIENT_LANDSCAPE;

    end;

    GlobalUnlock(hMode);

    {Run the Report}

    Crpe1.Execute;

  end;

  StrDispose(lpPort);

  StrDispose(lpDriver);

  StrDispose(lpPrinter);

end;

The above code can be greatly simplified by using some of the other Printer object methods & properties:

procedure RunReport;

begin

  {Set ReportName}

  Crpe1.ReportName := 'C:\test.rpt';

  {Preserve Orientation from Report}

  Crpe1.Printer.PreserveRptSettings[prOrientation];

  {Prompt for Printer at Execute}

  Crpe1.Printer.ShowDialog := True;

  {Run the Report}

  Crpe1.Execute;

end;


Orientation property

See also	Example

Applies to

Printer

Declaration

property Orientation: TCrOrientation;

Type

TCrOrientation = (orDefault, orPortrait, orLandscape);

Description

The Orientation property can be used to specify a particular orientation for the Report.  To preserve the Orientation as it was when the Report was designed, use the PreserveRptSettings property.


Orientation property - See also
Related

Mode

PMode

DevMode Structure

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Orientation property - Example
Example

This example illustrates the use of the Orientation property:

{Set ReportName}

Crpe1.ReportName := 'C:\Company.rpt';

{Set the Orientation to Landscape}

Crpe1.Printer.Orientation := orLandscape;

{Run the Report to Window}

Crpe1.Output := toWindow;

Crpe1.Execute;


PMode property

See also	Example

Applies to

Printer

Declaration

property PMode: Pointer;

Description

The PMode property specifies a pointer to the DevMode structure associated with a certain Printer, and can be used to control DevMode-specific properties.  Note that it is no longer necessary to fill in a value for this property, since the Crystal component will obtain this information internally provided a valid value is specified in the Name property.

The Retrieve method will also fill the PMode property with a value from the Printer settings saved with the current Report, or the GetCurrent method can be used right after showing the Delphi PrintDialog to obtain the Printer information and fill the Printer properties with values.

Note for Windows NT

Sometimes we hear reports of people having difficulty changing the Paper Bin, or other DevMode properties, on Windows NT.  The code normally used would look something like this:

  Crpe1.ReportName := 'C:\Company.rpt';

  {Initialize the VCL's Printer Properties}

  Crpe1.Printer.GetCurrent;

  {Set the Paper Bin to Manual feed}

  Crpe1.Printer.PMode^.dmDefaultSource := DMBIN_MANUAL;

  {Set output to Printer}

  Crpe1.Output := toPrinter;

  {Print the Report}

  Crpe1.Execute;

If this does not work, it may be necessary to set the DevMode properties twice in order to get them to work consistently.  The above code example would be changed to look like this:

  Crpe1.ReportName := 'C:\Company.rpt';

  {Clear the Printer properties to be safe}

  Crpe1.Printer.Clear;

  {Initialize the VCL Printer properties with the currently selected Printer}

  Crpe1.Printer.GetCurrent(False);

  {Set the DevMode paper bin member}

  Crpe1.Printer.PMode^.dmDefaultSource := DMBIN_MANUAL;

  {Send the settings to the CRPE}

  Crpe1.Printer.Send;

  {Retrieve the settings: bin is probably set back to default}

  Crpe1.Printer.Retrieve;

  {Set the Devmode paper bin member again}

  Crpe1.Printer.PMode^.dmDefaultSource := DMBIN_MANUAL;

  {Send the settings to the CRPE again}

  Crpe1.Printer.Send;

  {Run the Report}

  Crpe1.Execute;


PMode property - See also
Related

DevMode Structure

Mode

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PMode property - Example
Example

The following example shows how to use the PMode property to check DevMode settings for the Printer properties saved with the Report (Orientation in this case):

Crpe1.ReportName := 'C:\Company.rpt';

{Get Printer settings from Report}

Crpe1.Printer.Retrieve;

{Check the Orientation}

case Crpe1.Printer.PMode^.dmOrientation of

  DMORIENT_PORTRAIT  : ShowMessage('Orientation is Portrait');

  DMORIENT_LANDSCAPE : ShowMessage('Orientation is Landscape');

end;

Note

It might be necessary in some cases to typecase the PMode property, depending on the Compiler Options:

PDevMode(Crpe1.Printer.PMode)^.dmOrientation


Port property

See also	Example

Applies to

Printer

Declaration

property Port: TCrPrinterName;

Type

TCrPrinterName = string[80];

Description

The Port property contains the Port name of the Printer.

Traditionally, the Crystal VCL used to require the Name, Driver, Port and Mode properties to be set before it would change the Printer for a Report.  With the new Crystal component, however, this is not required.  The only property that needs to be specified is the Name.  The component will automatically fill in the other values (if the Printer Name is valid), when the component's Execute method is called.

If the Retrieve method is used, the Port property will contain the Port name for the Printer that was specified in the Report (or the default printer if the Printer specified in the Report is not valid).  Alternatively, the GetCurrent method can be called right after showing Delphi's PrintDialog, and it will also fill the Printer properties with values corresponding to the selected Printer.

Note

Do not attempt to set the Port property to 'FILE:' if the Printer Driver has not been set up that way.  It will not work.  Crystal Reports 7 has built-in support for printing to FILE via the OutputFileName property of the PrintOptions class.  For Crystal 5 and 6 users, see Setting Port to FILE.


Port property - See also
Related

Setting Port to FILE

PrintOptions.OutputFileName

Name

Driver

PMode

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Port property - Example
Example

This code uses the Printer properties to change Printers to one selected via the Print Dialog.  It also makes sure that the Orientation defined in the Report is preserved.

procedure RunReport;

var

  lpPrinter, lpDriver, lpPort : pChar;

  hMode                       : THandle;

  pMode                       : PDevMode;

  nOrientation                : integer;

begin

  {Set ReportName}

  Crpe1.ReportName := 'C:\Company.rpt';

  {Get Printer settings from Report}

  Crpe1.Printer.Retrieve;

  {Check the Orientation}

  hMode := Crpe1.Printer.Mode;

  pMode := GlobalLock(hMode);

  case pMode^.dmOrientation of

    DMORIENT_PORTRAIT  : nOrientation := 0;

    DMORIENT_LANDSCAPE : nOrientation := 1;

  end;

  GlobalUnlock(hMode);

  {Allocate memory for Printer property variables}

  try

    lpPrinter := StrAlloc(255);

    lpDriver := StrAlloc(255);

    lpPort := StrAlloc(255);

  except

    if lpPrinter <> nil then

      StrDispose(lpPrinter);

    if lpDriver <> nil then

      StrDispose(lpDriver);

    if lpPort <> nil then

      StrDispose(lpPort);

    Exit;

  end;

  {Show the PrintDialog}

  if PrintDialog1.Execute then  {if OK was clicked}

  begin

    {Get Selected Printer; could also use Crpe1.SelectPrinter}

    Printer.GetPrinter(lpPrinter, lpDriver, lpPort, hMode);

    {Set PrinterName}

    Crpe1.Printer.Name := StrPas(lpPrinter);

    {Set PrinterDriver: Check for Null - Win95 32-bit problem}

    if Length(StrPas(lpDriver)) <> 0 then

      Crpe1.Printer.Driver := StrPas(lpDriver)

    else

      Crpe1.Printer.Driver := StrPas(lpPrinter);

    {Set PrinterPort}

    Crpe1.Printer.Port := StrPas(lpPort);

    {Set PrinterMode}

    Crpe1.Printer.Mode := hMode;

    {Make sure the Orientation remains as in Report}

    pMode := GlobalLock(hMode);

    case nOrientation of

      0: pMode^.dmOrientation := DMORIENT_PORTRAIT;

      1: pMode^.dmOrientation := DMORIENT_LANDSCAPE;

    end;

    GlobalUnlock(hMode);

    {Run the Report}

    Crpe1.Execute;

  end;

  StrDispose(lpPort);

  StrDispose(lpDriver);

  StrDispose(lpPrinter);

end;

The above code can be greatly simplified by using some of the other Printer object methods & properties:

procedure RunReport;

begin

  {Set ReportName}

  Crpe1.ReportName := 'C:\Company.rpt';

  {Preserve Orientation from Report}

  Crpe1.Printer.PreserveRptSettings[prOrientation];

  {Prompt for Printer at Execute}

  Crpe1.Printer.ShowDialog := True;

  {Run the Report}

  Crpe1.Execute;

end;


PreserveRptSettings property

See also	Example

Applies to

Printer

Declaration

property PreserveRptSettings: TCrPreserveRptSettings;

Type

TCrPreserveRptSettings = set of TCrPreserveRptSet;

TCrPreserveRptSet = (prOrientation, prPaperSize, prPaperSource);

Description

PreserveRptSettings is used to keep certain Printer-related settings (Orientation, Paper Size, Paper Source) as they were when the Report was designed, even though another Printer is specified which may not have the same values specified by default.  To take full advantage of this property (and the Orientation property) requires some understanding of the Printer Setup dialog in the Crystal Reports designer:

Orientation:  This section of the Printer Setup dialog determines whether the Report is Portrait or Landscape.  This setting can be preserved as it is in the Report by adding prOrientation to the PreserveRptSettings set:

  Crpe1.Printer.PreserveRptSettings := [prOrientation];

Paper Size:  This section of the Printer Setup dialog determines what the Paper Size of the Report will be.  This setting can be preserved as it is in the Report by adding prPaperSize to the PreserveRptSettings set:

  Crpe1.Printer.PreserveRptSettings := [prPaperSize];

Paper Source:  This section of the Printer Setup dialog determines what the Paper Source on the Printer will be (ie. which Paper bin is used).  This setting can be preserved as it is in the Report by adding prPaperSource to the PreserveRptSettings set:

  Crpe1.Printer.PreserveRptSettings := [prPaperSource];

Preserving Paper Source may not function correctly yet on Windows NT 4.0 (see the Note below).

Default Properties:  This checkbox specifies whether the Report will obtain the DevMode properties from the specified Printer, of whether it will save it's own specific settings.  It is important if you plan to control or preserve Orientation, Paper Size, and Paper Source, that this box is UNchecked.  Notice that if any of the Orientation or Paper items (in the Print Setup dialog) are changed or edited, Default Properties will automatically be unchecked.

No Printer:  This checkbox specifies whether the Report will have any specific Printer information saved with it or not.  If this box is checked, it will be impossible to obtain any Printer specific information from the Report at runtime.  Make sure it is UNchecked, or PreserveRptSettings and Retrieve will not work as expected.

Note

There is currently a small problem with PreserveRptSettings for prPaperSource and Windows NT 4.0.  In NT4, the dmDefaultSource property of the DevMode structure cannot be modified.  The Paper Source (Bin) can be associated with a certain Page Size by the NT Administrator (in the Windows Control Panel Printer Setup).  Thereafter, any documents printed with that Page Size automatically go to the Bin associated with that size, regardless of any other bin setting.  Therefore, it appears that Paper Source has to be changed using other Windows API calls, which we have not yet implemented in the VCL.


PreserveRptSettings property - See also
Related

Orientation

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PreserveRptSettings property - Example
Example

The following code example uses the PreserveRptSettings property to preserve the PaperSize as defined in the Report, regardless of which Printer is chosen (not that this will only work if the Printer chosen supports that Page Size):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

with Crpe1.Printer do

begin

  {Set Name to 3rd Printer in Printers list}

  Name := Printer.Printers[2];

  {Set Orientation to Landscape}

  Orientation := orLandscape;

  {Preserve PaperSize as set in Report}

  PreserveRptSettings := [prPaperSize];

  {Do not show the PrintDialog on Execute}

  ShowDialog := False;

end;

Crpe1.Execute;


ShowDialog property

See also	Example

Applies to

Printer

Declaration

property ShowDialog: Boolean;

Description

The ShowDialog property can be used to bring up the Delphi Print dialog, which allows the user to change Printer property values.  This dialog looks like this:

It is the same as calling the ShowPrintDlg method, except that whereas ShowPrintDlg causes the Print dialog to appear as soon as it is called, ShowDialog calls the Print dialog only when the Crystal component's Execute method is called.

In practical terms, you would use ShowDialog if you always want the user to be prompted for a Printer choice before the Report runs.  If you only want the Print dialog to show optionally, if a button is pressed for example, then use the ShowPrintDlg method in the button click event.

With ShowDialog set to True, the Print dialog will appear whenever the Send method is called.  The Send method is automatically called whenever the Execute method for the component is called.

If you want the Print dialog to appear with a specific printer selected, set the Delphi Printers.PrinterIndex to the Printer desired, and call the GetCurrent method before calling Execute.  When the Print dialog appears, it will have that Printer selected by default.


ShowDialog property - See also
Related

ShowPrintDlg

PrintOptions.PromptForOptions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ShowDialog property - Example
Example

The following code illustrates how to use the ShowDialog property of the Printer object:

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Output := toPrinter;

  Crpe1.Printer.ShowDialog := True;

  {When Execute is called, the Printer dialog will appear}

  Crpe1.Execute;

Here is the same example, but in this case, we want the Printer dialog to appear with a certain Printer pre-selected:

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Output := toPrinter;

  Crpe1.Printer.ShowDialog := True;

  {Set the Delphi Printers list to the 4th Printer}

  Printers.PrinterIndex := 3;

  {When Execute is called, the Printer dialog will appear}

  Crpe1.Execute;


Create method

See also

Applies to

Printer

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Printer object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GetCurrent method

See also	Example

Applies to

Printer

Declaration

function GetCurrent(PreserveDevMode: boolean): boolean;

Description

The GetCurrent method obtains the current Printer information from the Delphi application environment and fills the component's Printer properties (Name, Driver, Port, Mode and PMode) with values.  It takes a boolean parameter, which specifies whether the function should clear the VCL's DevMode information or not.

The DevMode information is referenced by the PMode property, and contains information such as the Orientation, Paper Size, etc.

If the GetCurrent call is made after displaying a Delphi Print Dialog, PreserveDevMode should be set to True, since the user may have selected specific printer information via the Properties button in the Print Dialog.

If the Get Current call is made after setting the PrinterIndex property of Delphi's Printer array, then PreserveDevMode should be set to False, since the Printer is being changed and no specific properties have been set yet.

•	GetCurrent would be called with a "False" parameter after setting the PrinterIndex of the Delphi "Printer.Printers" array.

•	GetCurrent would be called with a "True" parameter after displaying the Delphi PrintDialog.

•	GetCurrent returns True if the call succeeded.

Note

The reason for the extra parameter, which was not present in earlier copies of the VCL, is that different internal processing is required to set the Printer device mode properly, depending on how the Printer was selected.


GetCurrent method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GetCurrent method - Example
Example

The following example illustrates the use of the GetCurrent method to obtain the current Printer information after setting the Printer.Printers array:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

{Set Printer array to 3rd Printer}

Printer.PrinterIndex := 2;

{Fetch the Printer Info into the VCL}

Crpe1.Printer.GetCurrent(False);

Crpe1.Execute;

This example shows the use of the GetCurrent method after a PrintDialog is called:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

{Show the PrintDialog}

if PrintDialog1.Execute then

begin

  {Fetch the Selected Printer Info into the VCL}

  Crpe1.Printer.GetCurrent(True);

  Crpe1.Execute;

end;


Retrieve method

See also	Example

Applies to

Printer

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Printer information from the Report.  If the Printer specified in the Report does not exist on the current computer, the default Printer information will be returned.  Returns True if the call succeeded.


Retrieve method - See also
Related

GetCurrent

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following example retrieves the Printer settings from a Report, and changes the Orientation setting if needed:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Destination := toPrinter;

Crpe1.Printer.Retrieve;

if Crpe1.Printer.Orientation <> orPortrait then

  Crpe1.Printer.Orientation := orPortrait;

Crpe1.Execute;


Send method

See also	Example

Applies to

Printer

Declaration

function Send: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The Send method sends the Printer values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.  It can be called manually in order to force a display of the Print Dialog if ShowDialog is set to True, but it would be better to use the ShowPrintDlg method instead.  There are three possible return values for Send:

cFalse	- Cancel was chosen on the Print Dialog (ShowDialog is set to True).

cTrue	- The Printer properties were sent to the Print Engine successfully.

cDefault	- The Printer properties were not sent because the properties had not changed from the Report settings, or there was an error (an error would normally raise an exception).

Note

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the Printer settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally not necessary since it is handled automatically in the Execute method:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Printer.Name := 'HP Laserjet 4';

Crpe1.Printer.Send;

Crpe1.Execute;


ShowPrintDlg method

See also	Example

Applies to

Printer

Declaration

function ShowPrintDlg: boolean;

Description

The ShowPrintDlg method causes the Printer dialog to appear so that the user can select the Printer options directly from the dialog.  The dialog looks like this:

Any options selected on the dialog will automatically update the components Printer and PrintOptions properties when the OK button is clicked.  If Cancel is chosen, the Crystal component will not be updated.

Another way of doing the same thing is to set the ShowDialog property to True.  This will cause the same dialog to appear, but it will not appear until the Execute method for the main component is called.  If this method is used, and Cancel is selected from the Dialog, the Report will not be processed (ie. Execute will be exited before running the Report to completion).

If you do not want the user to see the PrintOptions part of the dialog, run the Delphi PrinterSeupDialog instead, and use the GetCurrent method after the dialog is closed.  If you only want them to change the PrintOptions properties and not the Printer properties, set the PrintOptions property PromptForOptions to True.


ShowPrintDlg method - See also
Related

ShowDialog

PrintOptions.PromptForOptions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ShowPrintDlg method - Example
Example

The following code illustrates one way of using the ShowPrintDlg method:

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Output := toPrinter;

  if Crpe1.Printer.ShowPrintDlg then

    Crpe1.Execute;


Clear method

See also	Example

Applies to

Printer

Declaration

procedure Clear;

Description

The Clear method can be used to set the Printer properties back to their default values:

Name := '';

Port := '';

Driver := '';;

Mode := 0;

PMode := nil;

Orientation := orDefault;

PreserveRptSettings := [];

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
Related

Retrieve

GetCurrent

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the Printer properties:

Crpe1.Printer.Clear;


DevMode Structure

See also

The following information describes the 32-bit DevMode structure for Delphi.  Note that dmDefaultSource cannot be changed via the DevMode structure for WindowsNT 4.0.  Different Windows API calls are required, for which we do not have a sample at this time.

type

  PDeviceMode = PDeviceModeA;

dmDeviceName: array[0..CCHDEVICENAME - 1] of AnsiChar;

dmSpecVersion: Word;

dmDriverVersion: Word;

dmSize: Word;

dmDriverExtra: Word;

dmFields: DWORD;

dmOrientation: SHORT;

dmPaperSize: SHORT;

dmPaperLength: SHORT;

dmPaperWidth: SHORT;

dmScale: SHORT;

dmCopies: SHORT;

dmDefaultSource: SHORT;

dmPrintQuality: SHORT;

dmColor: SHORT;

dmDuplex: SHORT;

dmYResolution: SHORT;

dmTTOption: SHORT;

dmCollate: SHORT;

dmFormName: array[0..CCHFORMNAME - 1] of AnsiChar;

dmLogPixels: Word;

dmBitsPerPel: DWORD;

dmPelsWidth: DWORD;

dmPelsHeight: DWORD;

dmDisplayFlags: DWORD;

dmDisplayFrequency: DWORD;

dmICMMethod: DWORD;

dmICMIntent: DWORD;

dmMediaType: DWORD;

dmDitherType: DWORD;

dmReserved1: DWORD;

dmReserved2: DWORD;

  end;

dmDeviceName	Specifies the name of the device the driver supports--for example, "PCL/HP LaserJet" in the case of the Hewlett-Packard LaserJet. Each driver has a unique string.

dmSpecVersion	Specifies the version number of the DEVMODE structure. For Windows version 3.1, this value should be 0x30A

dmDriverVersion	Specifies the printer driver version number assigned by the printer driver developer.

dmSize	Specifies the size, in bytes, of the DEVMODE structure. (This value does not include the optional dmDriverData member for device-specific data, which can follow the structure.) If an application manipulates only the driver-independent portion of the data, it can use this member to find out the length of the structure without having to account for different versions.

dmDriverExtra	Specifies the size, in bytes, of the optional dmDriverData member for device-specific data, which can follow the structure. If an application does not use device-specific information, it should set this member to zero.

dmFields	Specifies a set of flags that indicate which of the remaining members in the DEVMODE structure have been initialized. It can be any combination (or it can be none) of the following values:

Constant	Value

DM_ORIENTATION	1

DM_PAPERSIZE	2

DM_PAPERLENGTH	4

DM_PAPERWIDTH	8

DM_SCALE	$10

DM_COPIES	$100

DM_DEFAULTSOURCE	$200

DM_PRINTQUALITY	$400

DM_COLOR	$800

DM_DUPLEX	$1000

DM_YRESOLUTION	$2000

DM_TTOPTION	$4000

DM_COLLATE	$8000

DM_FORMNAME	$10000

DM_LOGPIXELS	$20000

DM_BITSPERPEL	$40000

DM_PELSWIDTH	$80000

DM_PELSHEIGHT	$100000

DM_DISPLAYFLAGS	$200000

DM_DISPLAYFREQUENCY	$400000

DM_RESERVED1	$800000

DM_RESERVED2	$1000000

DM_ICMMETHOD	$2000000

DM_ICMINTENT	$4000000

DM_MEDIATYPE	$8000000

DM_DITHERTYPE	$10000000

NOTE:  A printer driver supports only those members that are appropriate for the printer technology.

dmOrientation	Specifies the orientation of the paper. It can be either of the following:

Constant	Value

DMORIENT_PORTRAIT	1

DMORIENT_LANDSCAPE	2

dmPaperSize	Specifies the size of the paper to print on.  This member may be set to zero if the length and width of the paper are specified by the dmPaperLength and dmPaperWidth members, respectively.  Otherwise, the dmPaperSize member can be set to one of the following predefined values:

Constant	Value	Description

DMPAPER_LETTER	1	{Letter 8 12 x 11 in}

DMPAPER_FIRST	DMPAPER_LETTER

DMPAPER_LETTERSMALL	2	{Letter Small 8 12 x 11 in}

DMPAPER_TABLOID	3	{Tabloid 11 x 17 in}

DMPAPER_LEDGER	4	{Ledger 17 x 11 in}

DMPAPER_LEGAL	5	{Legal 8 12 x 14 in}

DMPAPER_STATEMENT	6	{Statement 5 12 x 8 12 in}

DMPAPER_EXECUTIVE	7	{Executive 7 14 x 10 12 in}

DMPAPER_A3	8	{A3 297 x 420 mm}

DMPAPER_A4	9	{A4 210 x 297 mm}

DMPAPER_A4SMALL	10	{A4 Small 210 x 297 mm}

DMPAPER_A5	11	{A5 148 x 210 mm}

DMPAPER_B4	12	{B4 (JIS) 250 x 354}

DMPAPER_B5	13	{B5 (JIS) 182 x 257 mm}

DMPAPER_FOLIO	14	{Folio 8 12 x 13 in}

DMPAPER_QUARTO	15	{Quarto 215 x 275 mm}

DMPAPER_10X14	16	{10x14 in}

DMPAPER_11X17	17	{11x17 in}

DMPAPER_NOTE	18	{Note 8 12 x 11 in}

DMPAPER_ENV_9	19	{Envelope #9 3 78 x 8 78}

DMPAPER_ENV_10	20	{Envelope #10 4 18 x 9 12}

DMPAPER_ENV_11	21	{Envelope #11 4 12 x 10 38}

DMPAPER_ENV_12	22	{Envelope #12 4 \276 x 11}

DMPAPER_ENV_14	23	{Envelope #14 5 x 11 12}

DMPAPER_CSHEET	24	{C size sheet}

DMPAPER_DSHEET	25	{D size sheet}

DMPAPER_ESHEET	26	{E size sheet}

DMPAPER_ENV_DL	27	{Envelope DL 110 x 220mm}

DMPAPER_ENV_C5	28	{Envelope C5 162 x 229 mm}

DMPAPER_ENV_C3	29	{Envelope C3  324 x 458 mm}

DMPAPER_ENV_C4	30	{Envelope C4  229 x 324 mm}

DMPAPER_ENV_C6	31	{Envelope C6  114 x 162 mm}

DMPAPER_ENV_C65	32	{Envelope C65 114 x 229 mm}

DMPAPER_ENV_B4	33	{Envelope B4  250 x 353 mm}

DMPAPER_ENV_B5	34	{Envelope B5  176 x 250 mm}

DMPAPER_ENV_B6	35	{Envelope B6  176 x 125 mm}

DMPAPER_ENV_ITALY	36	{Envelope 110 x 230 mm}

DMPAPER_ENV_MONARCH	37	{Envelope Monarch 3.875 x 7.5 in}

DMPAPER_ENV_PERSONAL	38	{6 34 Envelope 3 58 x 6 12 in}

DMPAPER_FANFOLD_US	39	{S Std Fanfold 14 78 x 11 in}

DMPAPER_FANFOLD_STD_GERMAN	40	{German Std Fanfold 8 12 x 12 in}

DMPAPER_FANFOLD_LGL_GERMAN	41	{German Legal Fanfold 8 12 x 13 in}

DMPAPER_ISO_B4	42	{B4 (ISO) 250 x 353 mm}

DMPAPER_JAPANESE_POSTCARD	43	{Japanese Postcard 100 x 148 mm}

DMPAPER_9X11	44	{9 x 11 in}

DMPAPER_10X11	45	{10 x 11 in}

DMPAPER_15X11	46	{15 x 11 in}

DMPAPER_ENV_INVITE	47	{Envelope Invite 220 x 220 mm}

DMPAPER_RESERVED_48	48	{RESERVED--DO NOT USE}

DMPAPER_RESERVED_49	49	{RESERVED--DO NOT USE}

DMPAPER_LETTER_EXTRA	50	{Letter Extra 9 \275 x 12 in}

DMPAPER_LEGAL_EXTRA	51	{Legal Extra 9 \275 x 15 in}

DMPAPER_TABLOID_EXTRA	52	{Tabloid Extra 11.69 x 18 in}

DMPAPER_A4_EXTRA	53	{A4 Extra 9.27 x 12.69 in}

DMPAPER_LETTER_TRANSVERSE	54	{Letter Transverse 8 \275 x 11 in}

DMPAPER_A4_TRANSVERSE	55	{A4 Transverse 210 x 297 mm}

DMPAPER_LETTER_EXTRA_TRANSVERSE	56	{Letter Extra Transverse 9\275x12 in}

DMPAPER_A_PLUS	57	{SuperASuperAA4 227 x 356 mm}

DMPAPER_B_PLUS	58	{SuperBSuperBA3 305 x 487 mm}

DMPAPER_LETTER_PLUS	59	{Letter Plus 8.5 x 12.69 in}

DMPAPER_A4_PLUS	60	{A4 Plus 210 x 330 mm}

DMPAPER_A5_TRANSVERSE	61	{A5 Transverse 148 x 210 mm}

DMPAPER_B5_TRANSVERSE	62	{B5 (JIS) Transverse 182 x 257 mm}

DMPAPER_A3_EXTRA	63	{A3 Extra 322 x 445 mm}

DMPAPER_A5_EXTRA	$40	{A5 Extra 174 x 235 mm}

DMPAPER_B5_EXTRA	65	{B5 (ISO) Extra 201 x 276 mm}

DMPAPER_A2	66	{A2 420 x 594 mm}

DMPAPER_A3_TRANSVERSE	67	{A3 Transverse 297 x 420 mm}

DMPAPER_A3_EXTRA_TRANSVERSE	68	{A3 Extra Transverse 322 x 445 mm}

DMPAPER_LAST	DMPAPER_A3_EXTRA_TRANSVERSE

DMPAPER_USER	$100

dmOrientation	Specifies the orientation of the paper. It can be either of the following:

dmPaperLength	Specifies a paper length, in tenths of a millimeter. This parameter overrides the paper length specified by the dmPaperSize member, either for custom paper sizes or for such devices as dot-matrix printers that can print on a variety of page sizes.

dmPaperWidth	Specifies a paper width, in tenths of a millimeter. This parameter overrides the paper width specified by the dmPaperSize member.

dmScale	Specifies the factor by which the printed output is to be scaled. The apparent page size is scaled from the physical page size by a factor of dmScale/100. For example, a letter-size paper with a dmScale value of 50 would contain as much data as a page of size 17 by 22 inches because the output text and graphics would be half their original height and width.

dmCopies	Specifies the number of copies printed if the device supports multiple-page copies.

dmDefaultSource	Specifies the default bin from which the paper is fed. The application can override this value by using the GETSETPAPERBINS escape. This member can be one of the following values:

Constant	Value

DMBIN_UPPER 	1

DMBIN_FIRST 	DMBIN_UPPER

DMBIN_ONLYONE 	1

DMBIN_LOWER 	2

DMBIN_MIDDLE 	3

DMBIN_MANUAL 	4

DMBIN_ENVELOPE 	5

DMBIN_ENVMANUAL 	6

DMBIN_AUTO 	7

DMBIN_TRACTOR 	8

DMBIN_SMALLFMT 	9

DMBIN_LARGEFMT 	10

DMBIN_LARGECAPACITY 	11

DMBIN_CASSETTE 	14

DMBIN_FORMSOURCE 	15

DMBIN_LAST 	DMBIN_FORMSOURCE

DMBIN_USER 	$100 {device specific bins start here}

NOTE:  A range of values is reserved for device-specific bins. To be consistent with initialization information, the GETSETPAPERBINS and ENUMPAPERBINS escapes use these values.

dmPrintQuality	Specifies the printer resolution. Following are the four predefined device-independent values:

Constant	Value

DMRES_DRAFT	(-1)

DMRES_LOW 	(-2)

DMRES_MEDIUM	(-3)

DMRES_HIGH	(-4)

NOTE:  If a positive value is given, it specifies the number of dots per inch (DPI) and is therefore device-dependent.

NOTE:  If the printer initializes the dmYResolution member, the dmPrintQuality member specifies the x-resolution of the printer, in dots per inch.

dmColor	Specifies whether a color printer is to render color or monochrome output. Possible values are:

Constant	Value

DMCOLOR_MONOCHROME	1

DMCOLOR_COLOR	2

dmDuplex	Specifies duplex (double-sided) printing for printers capable of duplex printing. This member can be one of the following values:

Constant	Value

DMDUP_SIMPLEX	(1)

DMDUP_VERTICAL	(2)

DMDUP_HORIZONTAL	(3)

dmYResolution	Specifies the y-resolution of the printer, in dots per inch. If the printer initializes this member, the dmPrintQuality member specifies the x-resolution of the printer, in dots per inch.

dmTTOption	Specifies how TrueType fonts should be printed. It can be one of the following values:

Constant	Value	Description

DMTT_BITMAP	1	{print TT fonts as graphics}

DMTT_DOWNLOAD	2	{download TT fonts as soft fonts}

DMTT_SUBDEV	3	{substitute device fonts for TT fonts}

DMTT_DOWNLOAD_OUTLINE	4	{download TT fonts as outline soft fonts}

dmCollate	Specifies whether collation should be used when printing multiple copies.  (This member is ignored unless the printer driver indicates support for collation by setting the dmFields member to DM_COLLATE.)  This member can be one of the following values:

Constant	Value

DMCOLLATE_FALSE	0

DMCOLLATE_TRUE	1

NOTE:  Using DMCOLLATE_TRUE provides faster, more efficient output for collation, since the data is sent to the device driver just once, no matter how many copies are required. The printer is told to simply print the page again.

dmFormName	Windows NT: Specifies the name of the form to use; for example,"Letter" or "Legal".  A complete set of names can be retrieved by using the EnumForms function.  Windows 95: Printer drivers do not use this member.

dmLogPixels	Specifies the number of pixels per logical inch.

dmBitsPerPel	Windows NT: Specifies the color resolution, in bits per pixel, of the display device (for example: 4 bits for 16 colors, 8 bits for 256colors, or 16 bits for 65536 colors).  Windows 95: Display drivers use this member, for example, in the ChangeDisplaySettings function.  Printer drivers do not use this member.

dmPelsWidth	Windows NT: Specifies the width, in pixels, of the visible device surface.  Windows 95: Display drivers use this member, for example, in the ChangeDisplaySettings function.  Printer drivers do not use this member.

dmPelsHeight	Windows NT: Specifies the height, in pixels, of the visible device surface.  Windows 95: Display drivers use this member, for example, in the ChangeDisplaySettings function.  Printer drivers do not use this member.

dmDisplayFlags	Windows NT: Specifies the device's display mode.  This member can be one of the following values:

Constant	Value	Description

DM_GRAYSCALE	1	Specifies that the display is a NON-color device.  If this flag is not set, color is assumed.

DM_INTERLACED	2	Specifies that the display mode is interlaced.  If the flag is not set, NON-interlaced is assumed.  Windows 95: Display drivers use this member, for example, in the ChangeDisplaySettings function.  Printer drivers do not use this member.

dmDisplayFrequency  Windows NT: Specifies the frequency, in hertz (cycles per second), of the display device in a particular mode.  Windows 95: Display drivers use this member, for example, in the ChangeDisplaySettings function.  Printer drivers do not use this member.

dmICMMethod	Windows 95: Specifies how ICM is handled.  For a non-ICM application, this member determines if ICM is enabled or disabled.  For ICM applications, Windows examines this member to determine how to handle ICM support. This member can be one of the following predefined values, or a driver-defined value greater than the value of DMICMMETHOD_USER:Windows NT: This member is not supported on Windows NT.

Constant	Value	Description

DMICMMETHOD_NONE	1	Windows 95 only: Specifies that ICM is disabled.

DMICMMETHOD_SYSTEM	2	Windows 95 only: Specifies that ICM is handled by Windows.

DMICMMETHOD_DRIVER	3	Windows 95 only: Specifies that ICM is handled by the device driver.

DMICMMETHOD_DEVICE	4	Windows 95 only: Specifies that ICM is handled by the destination device.  The printer driver must provide a user interface for setting this member.  Most printer drivers support only the DMICMMETHOD_SYSTEM or DMICMMETHOD_NONE value.  Drivers for PostScript printers support all values.

DMICMMETHOD_USER	$100 Device-specific methods start here

dmICMIntent	Windows 95: Specifies which of the three possible color matching methods, or intents, should be used by default.  This member is primarily for non-ICM applications.  ICM applications can establish intents by using the ICM functions.  This member can be one of the following predefined values, or a driver defined value greater than the value of DMICM_USER:Windows NT: This member is not supported on Windows NT.

DMICM_SATURATE    	1	{Maximize color saturation}

DMICM_CONTRAST    	2	{Maximize color contrast}

DMICM_COLORMETRIC 	3	{Use specific color metric}

DMICM_USER	$100	{Device-specific intents start here}

dmMediaType	Windows 95: Specifies the type of media being printed on.  The member can be one of the following predefined values, or a driver-defined value greater than the value of DMMEDIA_USER:Windows NT: This member is not supported on Windows NT.

Constant	Value	Description

DMMEDIA_STANDARD	1	Standard paper

DMMEDIA_TRANSPARENCY	2	Transparency

DMMEDIA_GLOSSY	3	Glossy paper

dmDitherType	Windows 95: Specifies how dithering is to be done.  The member can be one of the following predefined values, or a driver-defined value greater than the value of DMDITHER_USER: Windows NT: This member is not supported on Windows NT.

Constant	Value	Description

DMDITHER_NONE	1	No dithering

DMDITHER_COARSE	2	Dither with a coarse brush

DMDITHER_FINE	3	Dither with a fine brush

DMDITHER_LINEART	4	LineArt dithering

DMDITHER_ERRORDIFFUSION	5	LineArt dithering

DMDITHER_RESERVED6	6	LineArt dithering

DMDITHER_RESERVED7 	7	LineArt dithering

DMDITHER_RESERVED8 	8	LineArt dithering

DMDITHER_RESERVED9 	9	LineArt dithering

DMDITHER_GRAYSCALE 	10	Device does gray-scaling

DMDITHER_USER 	256	Device-specific dithers start here

dmReserved1	Windows 95: Not used; must be zero.Windows NT: This member is not supported on Windows NT.

dmReserved2	Windows 95: Not used; must be zero.Windows NT: This member is not supported on Windows NT.

Remarks

A device driver's private data follows the public portion of the DEVMODE structure.  The size of the public data can vary for different versions of the structure.  The dmSize member specifies the number of bytes of public data, and the dmDriverExtra member specifies the number of bytes of private data.


DevMode Structure - See also
Related

Mode

PMode

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Setting Port to FILE

See also

A request we get quite often is that developers would like to set the Port to something other than what is specified in the Printer driver.  The most common use of this is to set the output to FILE.  This used to work with earlier Crystal versions, but in 5.x.x.108 and 6.0 of the Print Engine, this no longer works.  The reason for the change is that the previous method was not reliable.  This issue has been addressed in Seagate Crystal Reports 7, by the addition of an OutputFileName property to the PrintOptions object.

For users of Crystal 5.0 and 6.0, the only work-around is to create another Printer Driver in Windows that is set to go to the desired Port, and then switch to that Driver when a different Port setting is desired.  This however raises another question.  When a Report is printed to FILE, a prompt dialog appears requesting the user to enter the destination Filename.  This is not always convenient, especially in cases where Reports must be run in batches, and possibly overnight when there is no one around to enter the destination Filenames.  This problem can be worked around by using Windows API calls to obtain the handle to the prompting dialog, and then using that handle to pass the Filename in via code.  Here is an example of how this could be done in Delphi:

{SendFilename is called after "Print To File" dialog appears}

procedure SendFilename;

var

  aFile: array[0..255] of char;

  hDlg : Hwnd;

begin

  {Get the "Print To File" Dialog handle}

  hDlg := FindWindow(nil, 'Print To File');

  {If it was found...}

  if hDlg > 0 then

  begin

    {Copy the new Filename to the buffer}

    StrCopy(aFile, 'C:\Reports\Report1.prn');

    {Send the Text to the Edit field of the Dialog}

    SendDlgItemMessage(hDlg, 1152, WM_SETTEXT, 0, LongInt(@aFile));

    {Show the Dialog: If this isn't done, WM_LBUTTONDOWN needs to be sent twice}

    SendMessage(hDlg, WM_SHOWWINDOW,0,0);

    {Send a Button Down to the OK button of the Dialog}           SendDlgItemMessage(hDlg,1,WM_LBUTTONDOWN,0,0);

    {Send a Button Up to the OK button of the Dialog}       SendDlgItemMessage(hDlg,1,WM_LBUTTONUP,0,0);

  end;

end;

Note

The above code was tested on Windows95 and is offered as a possible work-around.  It is not guaranteed to work on all platforms and will probably need to be modified for WindowsNT.  If the PrintToFile dialog differs the edit field ID number for the filename will also probably be different.  Don't attempt this unless you have a reasonable knowledge of Windows API calls, or avoid the problem by upgrading to Crystal Reports 7.


Setting Port to File - See also
Related

Port

Name

Driver

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Orientation
Orientation:  This section of the Printer Setup dialog determines whether the Report is Portrait or Landscape.  This setting can be preserved as it is in the Report by adding prOrientation to the PreserveRptSettings set:

Crpe1.Printer.PreserveRptSettings := [prOrientation];


Paper Size
Paper Size:  This section of the Printer Setup dialog determines what the Paper Size of the Report will be.  This setting can be preserved as it is in the Report by adding prPaperSize to the PreserveRptSettings set:

Crpe1.Printer.PreserveRptSettings := [prPaperSize];


Paper Source
Paper Source:  This section of the Printer Setup dialog determines what the Paper Source on the Printer will be (ie. which Paper bin is used).  This setting can be preserved as it is in the Report by adding prPaperSource to the PreserveRptSettings set:

Crpe1.Printer.PreserveRptSettings := [prPaperSource];

Note

There is currently a small problem with PreserveRptSettings for prPaperSource and Windows NT 4.0.  In NT4, the dmDefaultSource property of the DevMode structure cannot be modified.  The Paper Source (Bin) can be associated with a certain Page Size by the NT Administrator (in the Windows Control Panel Printer Setup).  Thereafter, any documents printed with that Page Size automatically go to the Bin associated with that size, regardless of any other bin setting.  Therefore, it appears that Paper Source has to be changed using other Windows API calls, which we have not yet implemented in the VCL.


Default Properties
Default Properties:  This checkbox specifies whether the Report will obtain the DevMode properties from the specified Printer, of whether it will save it's own specific settings.  It is important if you plan to control or preserve Orientation, Paper Size, and Paper Source, that this box is UNchecked.  Notice that if any of the Orientation or Paper items (in the Print Setup dialog) are changed or edited, Default Properties will automatically be unchecked.


No Printer
No Printer:  This checkbox specifies whether the Report will have any specific Printer information saved with it or not.  If this box is checked, it will be impossible to obtain any Printer specific information from the Report at runtime.  Make sure it is UNchecked, or PreserveRptSettings and Retrieve will not work as expected.


CopyFrom method

See also	Example

Applies to

Printer

Declaration

procedure CopyFrom(Source: TCrpePrinter);

Description

The CopyFrom method copies the Printer property values from another TCrpePrinter object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Printer property values to a temporary TCrpePrinter object:

var

tempPrinter : TCrpePrinter;

begin

tempPrinter := TCrpePrinter.Create;

tempPrinter.CopyFrom(Crpe1.Printer);

{...later, when finished with the temp object...}

tempPrinter.Free;

end;


SetCurrent method

See also	Example

Applies to

Printer

Declaration

function SetCurrent: boolean;

Description

The SetCurrent method takes the Printer that is currently specified in the VCL and makes it the selected printer in the Delphi application environment.  Therefore, if a Print Dialog is called after using the SetCurrent method, it should have the Printer specified in the VCL as the default choice when the Print Dialog first appears.  If there is specific devmode information also specified in the VCL (Orientation, etc.) this also should appear when the Properties button is clicked in the Print Dialog.

Note

The ShowPrintDlg method automatically calls SetCurrent, so if you are displaying the PrintDialog via this method, there is no need to call SetCurrent before bringing up the Print Dialog.


SetCurrent method - See also
Related

ShowPrintDlg method

ShowDialog property

DevMode Structure

Mode

PMode

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SetCurrent method - Example
Example

The following example copies all the Printer property values to a temporary TCrpePrinter object:

var

tempPrinter : TCrpePrinter;

begin

tempPrinter := TCrpePrinter.Create;

tempPrinter.CopyFrom(Crpe1.Printer);

{...later, when finished with the temp object...}

tempPrinter.Free;

end;


PrintOptions

See also	Properties & Methods	Example

Declaration

property PrintOptions: TCrpePrintOptions;

Types

TCrpePrintOptions = class(TPersistent)

Description

The PrintOptions object, along with the Printer object, contains the properties that apply when setting the Output property to go toPrinter:

•	The Collation property refers to the printing of multiple copies of a Report, and whether they will print out as page 1,2,3, etc., or whether they will print out as 1,1,2,2,3,3, etc.

•	The Copies  property specifies the number of copies of the Report.

•	The StartPage property specifies the first page that will be printed.

•	The StopPage property specifies the last page that will be printed.

•	The OutputFileName property specifies a filename that the Report will be printed to (optional).

•	The Retrieve method can be used to get the current Report values for these properties.

•	The Clear method can be used to set them back to default.

•	The PromptForOptions property can be used to bring up a prompt dialog to allow the user to select the values for the PrintOptions properties.


PrintOptions - See also
Related

Printer

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintOptions - Properties & Methods
PrintOptions:

Properties & Methods

PrintOptions	TCrpe Component

Properties

Collation

Copies

OutputFileName

PromptForOptions

StartPage

StopPage

Methods

Clear

CopyFrom

Retrieve

Send

Constructor

Create


PrintOptions - Example
Example

This code example changes the PrintOption properties to print out two copies of pages 2 & 3 from the Report,  collated:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

with Crpe1.PrintOptions do

begin

  Collation := Collated;

  Copies := 2;

  StartPage := 2;

  StopPage := 3;

end;

Crpe1.Execute;


Collation property

See also	Example

Applies to

PrintOptions

Declaration

property Collation: TCrCollation;

Type

TCrCollation = (Uncollated, Collated, DefaultCollation);

Description

Collation is applicable when printing out more than one copy of a Report.  It determines if the pages will be printed out by Report, or by page.

For example, if printing out two copies of a 3-page Report, setting Collation to Collated will cause all the pages to be printed out for the first copy, then all the pages for the next copy.  Setting Collation to Uncollated will cause two copies of page 1 to be printed, then two copies of page 2, then two copies of page 3.

•	The default VCL setting for Collation is DefaultCollation.

Note

This property only applies if Output is toPrinter.


Collation property - See also
Related

Copies

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Collation property - Example
Example

This code example changes the PrintOption properties to print out two copies of pages 2 & 3 from the Report,  collated:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

with Crpe1.PrintOptions do

begin

  Collation := Collated;

  Copies := 2;

  StartPage := 2;

  StopPage := 3;

end;

Crpe1.Execute;


Copies property

See also	Example

Applies to

PrintOptions

Declaration

property Copies: Word;

Description

Copies determines how many copies of a Report will be printed.

•	The default VCL setting for Copies is 1.

•	To leave Copies unchanged from the Report setting, set Copies to 0.

Note

This property only applies if Output is toPrinter.


Copies property - See also
Related

Collation

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Copies property - Example
Example

This code example changes the PrintOption properties to print out two copies of pages 2 & 3 from the Report,  collated:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

with Crpe1.PrintOptions do

begin

  Collation := Collated;

  Copies := 2;

  StartPage := 2;

  StopPage := 3;

end;

Crpe1.Execute;


StartPage property

See also	Example

Applies to

PrintOptions

Declaration

property StartPage: Word;

Description

StartPage determines which page the printing will start with.

•	The default VCL setting for StartPage is zero (0).

•	Setting StartPage to zero (0) will cause printing to begin with the first page of the Report.

Note

This property only applies if Output is toPrinter.


StartPage property - See also
Related

StopPage

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


StartPage property - Example
Example

This code example changes the PrintOption properties to print out two copies of pages 2 & 3 from the Report,  collated:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

with Crpe1.PrintOptions do

begin

  Collation := Collated;

  Copies := 2;

  StartPage := 2;

  StopPage := 3;

end;

Crpe1.Execute;


StopPage property

See also	Example

Applies to

PrintOptions

Declaration

property StopPage: Word;

Description

StopPage determines which page the printing will stop with.

•	The default VCL setting for StopPage is zero (0).

•	Setting StopPage to zero (0), or 65535, will cause printing to go from the StartPage to the last page of the Report.

Note

This property only applies if Output is toPrinter.


StopPage property - See also
Related

StartPage

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


StopPage property - Example
Example

This code example changes the PrintOption properties to print out two copies of pages 2 & 3 from the Report,  collated:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

with Crpe1.PrintOptions do

begin

  Collation := Collated;

  Copies := 2;

  StartPage := 2;

  StopPage := 3;

end;

Crpe1.Execute;


Create method

See also

Applies to

PrintOptions

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method

See also	Example

Applies to

PrintOptions

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the PrintOptions information from the Report.  Returns True if the call succeeded.


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following example retrieves the PrintOptions settings from a Report, and changes the Collation setting if needed:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Destination := toPrinter;

Crpe1.PrintOptions.Retrieve;

if Crpe1.PrintOptions.Copies > 1 then

  Crpe1.PrintOptions.Collation := Collated;

Crpe1.Execute;


Send method

See also	Example

Applies to

PrintOptions

Declaration

function Send: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The Send method sends the PrintOptions values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.  There are three possible return values:

cFalse	- Cancel was chosen on the PrintOptions dialog (PromptForOptions is set to True).

cTrue	- The PrintOptions were sent to the Print Engine successfully.

cDefault	- The PrintOptions were not sent because the properties had not changed from the Report settings, or there was an error (an error would normally raise an exception).

If PromptForOptions is set to True, the Send method can be used to trigger the display of the PrintOptions dialog before Execute is called, although it is not necessary, since Execute will call the Print Options' Send method anyway.  If you decide to use the Send method before Execute is called, be sure to turn PromptForOptions off after the dialog appears, or else it will appear again later when Execute is called.

Note

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

PromptForOptions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the PrintOptions settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

Crpe1.PrintOptions.PromptForOptions := True;

{If Cancel was not chosen on the prompt dialog}

if Crpe1.PrintOptions.Send <> cFalse then

  Crpe1.Execute;


Clear method

See also	Example

Applies to

PrintOptions

Declaration

procedure Clear;

Description

The Clear method can be used to set the PrintOptions properties back to their default values:

Copies    := TCRPE_DEFAULT_PRINTERCOPIES; {1}

Collation := DefaultCollation;            {No change}

OutputFileName   := '';

PromptForOptions := False;

StartPage := TCRPE_DEFAULT_STARTPAGE;     {0}

StopPage  := TCRPE_DEFAULT_STOPPAGE;      {0}

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the PrintOptions properties:

Crpe1.PrintOptions.Clear;


PromptForOptions property

See also	Example

Applies to

PrintOptions

Declaration

property PromptForOptions: boolean

Description

The PromptForOptions property can be used to bring up a dialog that will prompt the user for the various PrintOption property values.  This dialog is the same that appears when the Print button on the Preview Window is clicked, and looks like this:

The dialog will appear whenever the Send method is called (provided that PromptForOptions is set to True).  The Send method is automatically called whenever the Execute method for the component is called.  However it may be called manually as well.

This may be desirable in the event that you wish the PrintOptions dialog to appear with certain default options other than those stored in the current Report.  In such a case, the PrintOptions properties can first be set to the desired values, then sent into the Report, and then when the dialog later appears, it will be pre-set to those values.  See the Example for code details.


PromptForOptions property - See also
Related

Printer.ShowDialog

Printer.ShowPrintDialog

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PromptForOptions property - Example
Example

The following code illustrates how to use the PromptForOptions property of the PrintOptions object.  The PrintOptions dialog will appear with the values that are specified in the original Report, which may not be the same as what are specified in the Crystal component.  In order to get the dialog to appear with the current VCL options, we set the Options in the VCL, and then do a Send.  This updates the Report with the new values, and then when the dialog appears, it has those values as default.  Note that normally it is not necessary to call Send since this is done at Execute.  This particular case is an exception:

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Output := toPrinter;

  {First we turn off the Prompt}

  Crpe1.PrintOptions.PromptForOptions := False;

  {Set the Options we want}

  Crpe1.PrintOptions.Copies := 3;

  Crpe1.PrintOptions.Collation := Collated;

  Crpe1.PrintOptions.StartPage := 2;

  {Send those values into the Report}

  Crpe1.PrintOptions.Send;

  {Now turn the Prompt on}

  Crpe1.PrintOptions.PromptForOptions := True;

  {When Execute is called, the PrintOptions dialog will appear}

  Crpe1.Execute;

Here is the same example, but in this case, we are not worried about what defaults the PrintOptions dialog appears with, so there is no need to do a Send:

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Output := toPrinter;

  Crpe1.PrintOptions.PromptForOptions := True;

  {When Execute is called, the PrintOptions dialog will appear}

  Crpe1.Execute;


CopyFrom method

See also	Example

Applies to

PrintOptions

Declaration

procedure CopyFrom(Source: TCrpePrintOptions);

Description

The CopyFrom method copies the PrintOptions property values from another TCrpePrintOptions object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the PrintOptions property values to a temporary TCrpePrintOptions object:

var

tempPrintOptions : TCrpePrintOptions;

begin

tempPrintOptions := TCrpePrintOptions.Create;

tempPrintOptions.CopyFrom(Crpe1.PrintOptions);

{...later, when finished with the temp object...}

tempPrintOptions.Free;

end;


OutputFileName property

See also	Example

Applies to

PrintOptions

Declaration

property OutputFileName: TCrPrintFileName;

Type

TCrPrintFileName = string; {limited to 512 characters}

Description

The OutputFileName property can be used to print a Report to File.  It must not exceed 512 characters in length.

Note

This property requires Seagate Crystal Reports 7.0 or higher.


OutputFileName property - See also
Related

Export

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OutputFileName property - Example
Example

This code example changes the PrintOption properties to print to a file:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

Crpe1.PrintOptions.OutputFileName := 'C:\Company.prn';

Crpe1.Execute;


Connect

See also	Properties & Methods	Example

Declaration

property Connect: TCrpeConnect;

Types

TCrpeConnect = class(TPersistent)

Description

The Connect object contains the properties that refer to the Report LogOn information required to connect to an ODBC or SQL datasource.  It has the same four basic properties as LogOnInfo:

ServerName

UserID

Password

DatabaseName

Whereas LogOnInfo allows different LogOn parameters for each table, Connect takes one set of parameters and applies them to all the tables in a Report.  Therefore, if a Report is designed with tables from more than one Server, LogOnInfo should be used instead of Connect.  However, if the main Report uses one Server, and the Subreport uses another, then Connect can still be used, since it can apply to Subreports as well.

•	The Retrieve method will obtain the ServerName, UserID, and DatabaseName from the current Report, and fill the Connect properties with those values.  If these values are to remain the same as when the Report was designed, all that needs to be supplied is the Password.

•	The Test method can be used to test the connection once the four basic properties have been filled in.

•	The Propagate property is designed to take the LogOn information from the main Report and use it for the Subreports as well.  If Propagate is set to True for the main Report, the Connect information from the main Report will be used for all the Subreports.  But if Propagate is set to True on a Subreport, then only that Subreport will use the Connect parameters set in the main Report.  See the Example for an illustration of this.

Imporant!

In order to use the Connect properties, the Crpe1.ConnectMethod property must be set to useConnect.  This setting tells the VCL's Execute method which class to use for connecting: Connect or LogOnInfo.

Note

When running a Report that requires the Connect properties to be set (most SQL databases), make sure that the proper files have been installed in order for the connection to succeed:

•	If the connection is being established via an ODBC Data Source, make sure the ODBC driver has been installed, and the Data Source has been properly configured on the computer.

•	If the connection is being established via Crystal's native SQL drivers, make sure the Client layer has been installed and that the Database/BIN location is in the PATH statement of the AUTOEXEC.BAT file.

•	With Crystal's runtime engine, it is possible to change the database name that an ODBC Datasource is pointing to, without having to reconfigure the Datasource manually.  See CRWDC for the full explanation and examples.


Connect - See also
Related

LogOnInfo

LogOnPrivateInfo

LogOnServer

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Connect - Properties and Methods
Connect:

Properties & Methods

Connect	TCrpe Component

Properties

ServerName

UserID

Password

DatabaseName

Propagate

Methods

Clear

CopyFrom

Retrieve

Send

Test

Constructor

Create


Connect - Example
Example

The following code will use the Connect parameters for the main Report and apply them to all Subreports also:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useConnect;

Crpe1.Connect.Retrieve;

Crpe1.Connect.Password := 'Agent86';

Crpe1.Connect.Propagate := True;

Crpe1.Execute;

This example will apply the Connect parameters from the main Report to the first Subreport only:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useConnect;

{Retrieve the Subreports}

Crpe1.Subreports.Retrieve;

{Set the Connect Parameters}

Crpe1.Connect.Retrieve;

Crpe1.Connect.Password := 'Agent86';

{Switch to Subreport 1}

Crpe1.Subreports[1];

{Set the Connect Propagate flag for Subreport 1}

Crpe1.Connect.Propagate := True;

Crpe1.Execute;


DatabaseName property

See also	Example

Applies to

Connect

Declaration

property DatabaseName: string;

Description

This property contains the name of the Database being connected to.  Most SQL Servers require this parameter (Oracle is usually an exception to the rule).

Note

•	With Crystal's runtime engine, it is possible to change the database name or path that an ODBC Datasource is pointing to, without having to reconfigure the Datasource manually.  See CRWDC for the full explanation and examples.

•	When using an ODBC Datasource that goes to a PC-type database (dBase, FoxPro, Paradox, etc.), where the Datasource points to a directory, not an actual table, the DatabaseName property cannot be used to change the name of the database being used by the Report.  Use the Tables object instead.


DatabaseName property - See also
Related

ServerName

UserID

Password

Propagate

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DatabaseName property - Example
Example

The following example sets the Connect properties and tests the connection before running the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useConnect;

Crpe1.Connect.ServerName := 'WBSQLServer';

Crpe1.Connect.UserID := 'Elmer Fudd';

Crpe1.Connect.Password := 'Wabbit';

Crpe1.Connect.DatabaseName := 'Company1';

if Crpe1.Connect.Test then

  Crpe1.Execute

else

  ShowMessage('Error Connecting');


Password property

See also	Example

Applies to

Connect

Declaration

property Password: string;

Description

The Password property contains the user password required for logging on to a SQL Server.  This is not stored in the Report when it is saved (and therefore will not be returned by the Retrieve method), but must be provided before running the Report.


Password property - See also
Related

ServerName

UserID

DatabaseName

Propagate

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Password property - Example
Example

The following example sets the Connect properties and tests the connection before running the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useConnect;

Crpe1.Connect.ServerName := 'WBSQLServer';

Crpe1.Connect.UserID := 'Elmer Fudd';

Crpe1.Connect.Password := 'Wabbit';

Crpe1.Connect.DatabaseName := 'Company1';

if Crpe1.Connect.Test then

  Crpe1.Execute

else

  ShowMessage('Error Connecting');


Propagate property

See also	Example

Applies to

Connect

Declaration

property Propagate: boolean;

Description

The Propagate property causes the Connect information from the main Report to apply to any Subreports also.  Since the Connect object is created for Subreports as well, there are two ways of using this property:

1. Propagate is set to True for the main Report - This will cause all Subreports to use the same Connect values as the main Report.

2. Propagate is set to True for a Subreport - This will cause that particular Subreport to get it's Connect information from the main Report.  All other Subreports will not be affected.

Propagate is True by default.


Propagate property - See also
Related

ServerName

UserID

Password

DatabaseName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Propagate property - Example
Example

The following code will cause the Connect values to be used for any Subreports also:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useConnect;

Crpe1.Connect.ServerName := 'WBSQLServer';

Crpe1.Connect.UserID := 'Elmer Fudd';

Crpe1.Connect.Password := 'Wabbit';

Crpe1.Connect.DatabaseName := 'Company1';

Crpe1.Connect.Propagate := True;

if Crpe1.Connect.Test then

  Crpe1.Execute

else

  ShowMessage('Error Connecting');

The following code will cause the first Subreport to get it's Connect values from the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useConnect;

{Retrieve Subreports}

Crpe1.Subreports.Retrieve;

{Go to main Report}

Crpe1.Subreports[0];

{Set the main Report Connect}

Crpe1.Connect.ServerName := 'WBSQLServer';

Crpe1.Connect.UserID := 'Elmer Fudd';

Crpe1.Connect.Password := 'Wabbit';

Crpe1.Connect.DatabaseName := 'Company1';

{Go to first Subreport}

Crpe1.Subreports[1];

{Set Propagate for the Subreport Connect}

Crpe1.Connect.Propagate := True;

{Go back to main Report}

Crpe1.Subreports[0];

{Run the Report}

if Crpe1.Connect.Test then

  Crpe1.Execute

else

  ShowMessage('Error Connecting');


ServerName property

See also	Example

Applies to

Connect

Declaration

property ServerName: string;

Description

This property contains the name of the Server being connected to.  If the Report was created using Crystal's native SQL drivers, this will be the actual Server name.  If the Report was created using ODBC drivers, this will be the ODBC Data Source Name.


ServerName property - See also
Related

UserID

Password

DatabaseName

Propagate

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ServerName property - Example
Example

The following example sets the Connect properties and tests the connection before running the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useConnect;

Crpe1.Connect.ServerName := 'WBSQLServer';

Crpe1.Connect.UserID := 'Elmer Fudd';

Crpe1.Connect.Password := 'Wabbit';

Crpe1.Connect.DatabaseName := 'Company1';

if Crpe1.Connect.Test then

  Crpe1.Execute

else

  ShowMessage('Error Connecting');


UserID property

See also	Example

Applies to

Connect

Declaration

property UserID: string;

Description

This property contains the user name required to log on to the SQL Server.


UserID property - See also
Related

ServerName

Password

DatabaseName

Propagate

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


UserID property - Example
Example

The following example sets the Connect properties and tests the connection before running the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useConnect;

Crpe1.Connect.ServerName := 'WBSQLServer';

Crpe1.Connect.UserID := 'Elmer Fudd';

Crpe1.Connect.Password := 'Wabbit';

Crpe1.Connect.DatabaseName := 'Company1';

if Crpe1.Connect.Test then

  Crpe1.Execute

else

  ShowMessage('Error Connecting');


Create method

See also

Applies to

Connect

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method

See also	Example

Applies to

Connect

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Connect information from the Report.  The Connect information is obtained from the first table in the Report that has LogOn information (ie. the first SQL table located).  Returns True if the call was successful in obtaining Connect information.

Note

Since the Connect object also applies to Subreports, the Retrieve method will obtain the Connect for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the Connect settings for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate Connect settings for each Subreport (see Example).


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Connect.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  {Retrieve Subreports}

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.Connect.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

Connect

Declaration

function Send: boolean;

Description

The Send method sends the Connect values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that the ConnectMethod property is set to useConnect, and  SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Test

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the Connect settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.Connect.Send;


Test method

See also	Example

Applies to

Connect

Declaration

function Test: boolean;

Description

The Test method can be used to try out a connection after the Connect properties have been filled.


Test method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Test method - Example
Example

The Test method is used in the example below to check the Connect information before running a Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useConnect;

Crpe1.Connect.Retrieve;

Crpe1.Connect.Password := 'Agent86';

if Crpe1.Connect.Test then

  Crpe1.Execute

else

  ShowMessage('Error Connecting');


Clear method

See also	Example

Applies to

Connect

Declaration

procedure Clear;

Description

This method can be used to set the Connect properties to their default values:

ServerName   := '';

UserID       := '';

Password     := '';

DatabaseName := '';

Propagate    := True;

It is called automatically if the Clear method is called for the main component, or if a new report name is assigned to the ReportName property, but may be called in code as desired.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the Connect properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.Connect.Clear;

This code clears the Connect properties for the second Subreport:

Crpe1.Subreports[2];

Crpe1.Connect.Clear;


CopyFrom method

See also	Example

Applies to

Connect

Declaration

procedure CopyFrom(Source: TCrpeConnect);

Description

The CopyFrom method copies the Connect property values from another TCrpeConnect object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Connect property values to a temporary TCrpeConnect object:

var

tempConnect : TCrpeConnect;

begin

tempConnect := TCrpeConnect.Create;

tempConnect.CopyFrom(Crpe1.Connect);

{...later, when finished with the temp object...}

tempConnect.Free;

end;


CRWDC

See also

Applies to

Connect.DatabaseName

LogOnInfo.DatabaseName

With Crystal Reports 6 and higher, it is possible to change the Database, Table, or directory that an ODBC Datasource points to without having to reconfigure the ODBC Datasource manually.  The change is done via the DatabaseName property of the LogOnInfo or Connect objects.  The syntax required to make the change is in the following format:

<CRWDC>[Database Spec]=

The syntax is slightly different depending on which ODBC database driver the Report is using.  Here is a categorical list showing the appropriate syntax in each case:

SQL ODBC drivers

Crpe1.Connect.DatabaseName := '<CRWDC>Database=' + DatabaseName;

PC ODBC drivers

Access

Crpe1.Connect.DatabaseName := '<CRWDC>DBQ=' + Path\DatabaseName;

DBase

Crpe1.Connect.DatabaseName := '<CRWDC>DBQ=' + Path\;


CRWDC - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LogOnServer

See also	Properties & Methods	Example

Declaration

property LogOnServer: TCrpeLogOnServer;

Types

TCrpeLogOnServer = class(TPersistent)

Description

The LogOnServer object is a run-time only object that contains properties that allow for Logging onto a Server.  The difference between this object and the Connect and LogOnInfo objects is that the latter work on a table by table basis, setting the LogOn information for each table in a Report, whereas LogOnServer just opens a connection to a SQL Server and if the Report has that Server specified in it, it will use the connection.

The advantage to LogOnServer is that it is simple, and only needs to be opened once for any Reports (and Subreports) that use that particular Server, whereas the Connect and LogOnInfo properties need to be specified on a report by report basis.  The disadvantage is that it will not change the Server name that is specified in a Report, therefore it is not possible to use LogOnServer if the Server name is going to be different than when the Report was created.

The LogOn parameters for LogOnServer are similar to the other two objects:

ServerName

UserID

Password

DatabaseName

DLLName

DLLName specifies the name of the Seagate Crystal Reports DLL for the server or password-protected non-SQL table you want to log on to, for example, 'PDSODBC.DLL'.  DLL names have the following naming convention:  PDS*.DLL for SQL/ODBC databases.

•	The Retrieve method will create an item in the LogOnServer object for each unique ServerName it finds in the Report (including any Subreports), and fill all the properties of each item except for Password.

•	The LogOn and LogOff methods create and terminate the actual connection.

•	The Number property stores the connection number created by a successful LogOn.

•	The IndexOf method can be used to locate a specific LogOnServer item by it's connection Number.

Note

LogOff will not normally be successful unless the Report that uses the connection is first closed, by either changing the ReportName, or using the component's CloseJob method.


LogOnServer - See also
Related

Connect

LogOnInfo

LogOnPrivateInfo

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LogOnServer - Properties & Methods
LogOnServer:

Properties & Methods

LogOnServer	TCrpe Component

Properties

DLLName

ServerName

UserID

Password

DatabaseName

Number

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

IndexOf

LogOff

LogOn

Retrieve

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


LogOnServer - Example
Example

This example shows how to create a LogOnServer item manually, and fill the properties with values.  Finally, the LogOn method is called:

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

  if LogOn then

    ShowMessage('The LogOn ID is: ' + IntToStr(Number))

  else

    ShowMessage('Error Logging on to Server');

end;

This example shows how to create a LogOnServer item by retrieving the LogOn information from the Report.  This should only be done if the ServerName that the Report was created with is going to remain the same, since LogOnServer cannot be used to change ServerName:

Crpe1.LogOnServer.Retrieve;  {Retrieve LogOnServer info from Report}

if Crpe1.LogOnServer.Count > 0 then

begin

  Crpe1.LogOnServer[1];

  Crpe1.LogOnServer.Password := 'tiger';

  if not Crpe1.LogOnServer.LogOn then

    ShowMessage('Error Logging on to Server');

end;

This example shows how to log off a Server that has been Logged On using the LogOnServer property.  First the PrintJob must be closed, or the LogOff will fail.  Then the LogOnServer object must be set to the item that was used to LogOn (the IndexOf method can be used to search LogOnServer for a particular LogOn ID).  Finally an attempt is made to LogOff:

Crpe1.CloseJob;

Crpe1.LogOnServer[0];

if Crpe1.LogOnServer.LogOff then

  ShowMessage('LogOff Server successful')

else

   ShowMessage('LogOff Server failed');


DatabaseName property

See also	Example

Applies to

LogOnServer

Declaration

property DatabaseName: string;

Description

This property contains the name of the Database being connected to.  Most SQL Servers require this parameter (Oracle is usually an exception to the rule).


DatabaseName property - See also
Related

DLLName

ServerName

UserID

Password

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DatabaseName property - Example
Example

This example shows how to create a LogOnServer item manually, and fill the properties with values.  Finally, the LogOn method is called:

with Crpe1.LogOnServer do

begin

  Add;                     {Create a LogOnServer item}

  DLLName := 'PDSSQL.DLL'; {Crystal's Native MS SQL Server Driver}

  ServerName := 'enterprise';

  UserID := 'Kirk';

  Password := 'captain';

  DatabaseName := 'pubs';

  if LogOn then

    ShowMessage('The LogOn ID is: ' + IntToStr(Number))

  else

    ShowMessage('Error Logging on to Server');

end;


DLLName property

See also	Example

Applies to

LogOnServer

Declaration

property DLLName: string;

Description

The DLLName property refers to the name of the Crystal database DLL used to make the LogOn connection.  This must be the same as the one defined in the Report.  If ODBC drivers are being used to make the connection, the DLL Name is:

'PDSODBC.DLL'

If Crystal's native SQL drivers are being used to make the connection, the DLL naming convention is:

'PDS*.DLL'  {PDSORA7.DLL for Oracle, PDSSQL.DLL for MS SQL Server, PDSSYB10.DLL for Sybase System 10/11, etc.}

Notice that the 16-bit naming convention can be used even for 32-bit drivers.  The 32-bit names can also be used (P2SODBC.DLL, etc.) if desired.

Note

To determine the driver that the Report was designed with, load the Report into Crystal Reports, go to the Database menu in Crystal Reports 6.0 (or File | Report Options in Crystal Reports 5.0) and selecting the "Convert Database Driver" option.  The driver name is listed after the word "From:" in the dialog.


DLLName property - See also
Related

ServerName

UserID

Password

DatabaseName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DLLName property - Example
Example

This example shows how to create a LogOnServer item manually, and fill the properties with values.  Finally, the LogOn method is called:

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

  if LogOn then

    ShowMessage('The LogOn ID is: ' + IntToStr(Number))

  else

    ShowMessage('Error Logging on to Server');

end;


Item property

See also	Example

Applies to

LogOnServer

Declaration

property Item[const nIndex: integer]: TCrpeLogOnServer;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the LogOnServer object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  LogOnServer[2] is the same as LogOnServer.Item[2].

•	Item returns a reference to the LogOnServer object, so the LogOnServer properties can be used right after the subscript: LogOnServer[2].DatabaseName := 'MyDatabase';


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

end;

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver2';

  UserID := 'WILSON';

  Password := 'giraffe';

  DatabaseName := '';  {Not usually req'd for Oracle}

end;

{Set LogOnServer object back to first item}

Crpe1.LogOnServer.Item[0];

{Try Logging On}

if Crpe1.LogOnServer.LogOn then

  ShowMessage('The LogOn ID is: ' + IntToStr(Number))

else

  ShowMessage('Error Logging on to Server');

Crpe1.ReportName := 'C:\Company.rpt';

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

end;

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver2';

  UserID := 'WILSON';

  Password := 'giraffe';

  DatabaseName := '';  {Not usually req'd for Oracle}

end;

{Set LogOnServer object back to first item}

Crpe1.LogOnServer[0];

{Try Logging On}

if Crpe1.LogOnServer.LogOn then

  ShowMessage('The LogOn ID is: ' + IntToStr(Number))

else

  ShowMessage('Error Logging on to Server');


ItemIndex property

See also	Example

Applies to

LogOnServer

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current LogOnServer item number, or set the LogOnServer object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (LogOnServer[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the LogOnServer object is pointing to the first LogOnServer item:

if Crpe1.LogOnServer.ItemIndex <> 0 then

  Crpe1.LogOnServer[0];


Number property

See also	Example

Applies to

LogOnServer

Declaration

property Number: integer;

Description

Number is a read-only property that is filled with a value when the LogOn method is called.  Before the LogOn method is called, the Number property will have zero as a default value.

Each connection established via the LogOnServer's LogOn method will generate a unique LogOn number, which is stored in the Number property.  Therefore, if the Number value of a LogOnServer item is greater than zero, it indicates that a connection has been established for that Server.

The IndexOf method can be used to locate a specific number within the LogOnServer object.


Number property - See also
Related

IndexOf

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

This example shows how to create a LogOnServer item manually, and fill the properties with values.  Finally, the LogOn method is called, which puts a LogOn ID value in the Number property:

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

  if LogOn then

    ShowMessage('The LogOn ID is: ' + IntToStr(Number))

  else

    ShowMessage('Error Logging on to Server');

end;


Password property

See also	Example

Applies to

LogOnServer

Declaration

property Password: string;

Description

The Password property contains the user password required for logging on to a SQL Server.  This is not stored in the Report when it is saved (and therefore will not be returned by the Retrieve method), but must be provided before running the Report.


Password property - See also
Related

DLLName

ServerName

UserID

DatabaseName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Password property - Example
Example

This example shows how to create a LogOnServer item manually, and fill the properties with values.  Finally, the LogOn method is called:

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

  if LogOn then

    ShowMessage('The LogOn ID is: ' + IntToStr(Number))

  else

    ShowMessage('Error Logging on to Server');

end;


ServerName property

See also	Example

Applies to

LogOnServer

Declaration

property ServerName: string;

Description

This property contains the name of the Server being connected to.  If the Report was created using Crystal's native SQL drivers, this will be the actual Server name.  If the Report was created using ODBC drivers, this will be the ODBC Data Source Name.


ServerName property - See also
Related

DLLName

UserID

Password

DatabaseName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ServerName property - Example
Example

This example shows how to create a LogOnServer item manually, and fill the properties with values.  Finally, the LogOn method is called:

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

  if LogOn then

    ShowMessage('The LogOn ID is: ' + IntToStr(Number))

  else

    ShowMessage('Error Logging on to Server');

end;


UserID property

See also	Example

Applies to

LogOnServer

Declaration

property UserID: string;

Description

This property contains the user name required to log on to the SQL Server.


UserID property - See also
Related

DLLName

ServerName

Password

DatabaseName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


UserID property - Example
Example

This example shows how to create a LogOnServer item manually, and fill the properties with values.  Finally, the LogOn method is called:

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

  if LogOn then

    ShowMessage('The LogOn ID is: ' + IntToStr(Number))

  else

    ShowMessage('Error Logging on to Server');

end;


Create method

See also

Applies to

LogOnServer

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

LogOnServer

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

LogOnServer

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the LogOnServer object.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.LogOnServer.Retrieve;

  for cnt := 0 to (Crpe1.LogOnServer.Count - 1) do

    ListBox1.Items.Add(Crpe1.LogOnServer[cnt].ServerName;

end;


IndexOf method

See also	Example

Applies to

LogOnServer

Declaration

function IndexOf(LogNumber: integer): integer;

Description

The IndexOf method takes a LogOn number as a parameter and returns the numeric position of the LogOnServer item (in the LogOnServer object) that matches the LogOn number.  It can be used to locate a LogOnServer item that is to be logged off.


IndexOf method - See also
Related

Number

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

This example shows how to use the IndexOf method to locate an item in the LogOnServer object based on it's LogOn number value:

procedure LogOffByNumber(Num: integer);

begin

  Num := Crpe1.LogOnServer.IndexOf(Num);

  if not Crpe1.LogOnServer[Num].LogOff then

    ShowMessage('LogOff failed');

end;


LogOff method

See also	Example

Applies to

LogOnServer

Declaration

function LogOff: boolean;

Description

The LogOff method is used to terminate the connection to a Server that was logged onto using the LogOn method.  Returns True if the LogOff succeeded and False if the LogOff attempt failed.

Note

LogOff will not normally be successful unless the Report that uses the connection is first closed, by either changing the ReportName, or using the component's CloseJob method.


LogOff method - See also
Related

Number

LogOn

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LogOff method - Example
Example

This example shows how to use the IndexOf method to locate an item in the LogOnServer object based on it's LogOn number value, and then LogOff that item:

procedure LogOffByNumber(Num: integer);

begin

  Num := Crpe1.LogOnServer.IndexOf(Num);

  if not Crpe1.LogOnServer[Num].LogOff then

    ShowMessage('LogOff failed');

end;


LogOn method

See also	Example

Applies to

LogOnServer

Declaration

function LogOn: boolean;

Description

The LogOn method is used to create a connection to a SQL Server.  Before LogOn can be called, the following steps should be followed:

1. Add an item to the LogOnServer object, or use the Retrieve method.

2. Fill the item's properties (ServerName, Password, etc.) with relevant values (if Retrieve was used, only the Password needs to be specified).

3. Use the LogOn method to establish a connection.

If the LogOn was successful, a unique ID number will be stored in the Number property.  LogOn returns True if the LogOn attempt succeeded.


LogOn method - See also
Related

Number

LogOff

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LogOn method - Example
Example

This example shows how to create a LogOnServer item manually, and fill the properties with values.  Finally, the LogOn method is called, which puts a LogOn ID value in the Number property:

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

  if LogOn then

    ShowMessage('The LogOn ID is: ' + IntToStr(Number))

  else

    ShowMessage('Error Logging on to Server');

end;


Retrieve method

See also	Example

Applies to

LogOnServer

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the LogOnServer information from the Report.  Unlike most of the other methods for LogOnServer, in order for the Retrieve call to work there must be a Report specified in the ReportName property.

Retrieve will actually create one LogOnServer item for each unique set of LogOn information it finds in the Report (it will also scan Subreport Tables).  For example if there are two Tables in the Report going to two different Servers, then Retrieve will add two items to the LogOnServer object.

•	Be aware that calling Retrieve will clear the LogOnServer object of any previous information.

•	It is not necessary to retrieve Subreports first.  If they have not yet been retrieved, LogOnServer.Retrieve will automatically retrieve them.

•	If LogOn information was not found, the call returns False.


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method to obtain unique LogOnServer information from all the Tables in the Report and any Subreports.  It is not necessary to retrieve Subreports first, since LogOnServer will do this automatically if it has not been done yet:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.LogOnServer.Retrieve;

  {Put the ServerNames in a ListBox}

  for cnt := 0 to (Crpe1.LogOnServer.Count - 1) do

    ListBox1.Items.Add(Crpe1.LogOnServer[cnt].ServerName);

end;


Add method

See also	Example

Applies to

LogOnServer

Declaration

function Add: integer;

Description

The Add method adds an item to the LogOnServer object and sets the LogOnServer object index to that item.  If the Add method is used, the steps to using LogOnServer are:

1. Add an item to the LogOnServer object.

2. Fill the item's properties (ServerName, Password, etc.) with values.

3. Use the LogOn method to establish a connection.

Note

Alternatively, if a Report has been specified in the ReportName property, the Retrieve method can be used to fill the LogOnServer with LogOn information from the Report, in which case only the Password property will need to be filled in before calling the LogOn method.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The following code illustrates using the Add method to implement a LogOnServer connection:

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

  if LogOn then

    ShowMessage('The LogOn ID is: ' + IntToStr(Number))

  else

    ShowMessage('Error Logging on to Server');

end;


Clear method

See also	Example

Applies to

LogOnServer

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the LogOnServer object.  It will not automatically LogOff any currently connected Servers before clearing the LogOnServer information that has been stored.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the LogOnServer properties:

Crpe1.LogOnServer.Clear;


Delete method

See also	Example

Applies to

LogOnServer

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to delete an item from the LogOnServer object.  Note that Delete will not check to see if there is still a connection opened by that item.  Therefore, LogOff should be called first, if required.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The following code creates an item in the LogOnServer object, attempts a connection, logs off the connection and deletes the item:

with Crpe1.LogOnServer do

begin

  Add;                 {Create a LogOnServer item}

  DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

  if not LogOn then

    ShowMessage('Error Logging on Server')

  else

  begin

    if not LogOff then

      ShowMessage('Error Logging off Server');

  end;

  Crpe1.LogOnServer.Delete(Crpe1.LogOnServer.ItemIndex);

end;


CopyFrom method

See also	Example

Applies to

LogOnServer

Declaration

procedure CopyFrom(Source: TCrpeLogOnServer);

Description

The CopyFrom method copies the LogOnServer property values from another TCrpeLogOnServer object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the LogOnServer property values to a temporary TCrpeLogOnServer object:

var

tempLogOnServer : TCrpeLogOnServer;

begin

tempLogOnServer := TCrpeLogOnServer.Create;

tempLogOnServer.CopyFrom(Crpe1.LogOnServer);

{...later, when finished with the temp object...}

tempLogOnServer.Free;

end;


LogOnInfo

See also	Properties & Methods	Example

Declaration

property LogOnInfo: TCrpeLogOnInfo;

Types

TCrpeLogOnInfo = class(TPersistent)

Description

The LogOnInfo object is used to set the LogOn information for each table in the Report.  It applies to Reports based on SQL tables or ODBC datasources, as does the Connect property, and LogOnServer.

The difference between LogOnInfo and Connect is that LogOnInfo allows different LogOn parameters for each table, whereas Connect takes one set of parameters and applies them to all the tables in a Report.  Therefore, if a Report is designed with tables from more than one Server, LogOnInfo should be used instead of Connect.

LogOnInfo contains the basic Server information properties:

ServerName

UserID

Password

DatabaseName

As well, it contains read-only properties that display information about the Table Type and Crystal Database DLL used to access the Table:

TableType

DescriptiveName

DLLName

These properties will only have meaningful values if the Retrieve method is used to get the LogOn information from the Report.  Otherwise, if the manual Add method is used, these values will contain empty strings.

•	The PromptForLogOn property can be used to bring up a dialog prompting for LogOn information.

•	The Table property contains the Table number as defined in the Report.  This number represents the order in which the Tables were added to the Report, and can be viewed by opening the Report in the Crystal Reports Designer and going to the "Database | Set Location..." menu item.  The Tables appear in a list, and are numbered internally from top to bottom.

•	If the Retrieve method has been used, the Count method will yield the number of SQL tables in the Report, and is useful for looping constructs.

•	The Test method provides a useful means of testing the Table connectivity after the desired parameters have been changed.  This will reveal if the LogOn information is correct or not.

Imporant!

In order to use the LogOnInfo properties, the Crpe1.ConnectMethod property must be set to useLogOnInfo.  This setting tells the VCL's Execute method which class to use for connecting: Connect or LogOnInfo.


LogOnInfo - See also
Related

Connect

LogOnPrivateInfo

LogOnServer

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LogOnInfo - Properties & Methods
LogOnInfo:

Properties & Methods

LogOnInfo	TCrpe Component

Properties

ServerName

UserID

Password

DatabaseName

PromptForLogOn

SQLTablesOnly

Key

Table

Table Information

DescriptiveName

DLLName

TableType

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

Send

Test

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


LogOnInfo - Example
Example

This example shows how to use the LogOnInfo object to supply a new UserID and Password for the SQL tables in a Report.  It is assumed that the ServerName and DatabaseName will remain the same as they were when the Report was designed.  Notice that the code tests each table to see if the LogOn information works:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useLogOnInfo;

Crpe1.LogOnInfo.Retrieve;

for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do

begin

  Crpe1.LogOnInfo[cnt];

  Crpe1.LogOnInfo.UserID := 'Maxwell Smart';

  Crpe1.LogOnInfo.Password := 'Agent86';

  if Crpe1.LogOnInfo.Test then

    ShowMessage('LogOn information is good')

  else

    ShowMessage('LogOn information is not good');

end;


DatabaseName property

See also	Example

Applies to

LogOnInfo

Declaration

property DatabaseName: string;

Description

This property contains the name of the Database being connected to.  Most SQL Servers require this parameter (Oracle is usually an exception to the rule).  DatabaseName is limited to 128 characters in length (anything greater than that will be truncated).


DatabaseName property - See also
Related

ServerName

UserID

Password

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DatabaseName property - Example
Example

This example shows how to retrieve LogOn information and then set it for each item:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ConnectMethod := useLogOnInfo;

  Crpe1.LogOnInfo.Retrieve;

  for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do

  begin

    Crpe1.LogOnInfo[cnt].ServerName := 'Enterprise';

    Crpe1.LogOnInfo[cnt].UserID := 'Kirk';

    Crpe1.LogOnInfo[cnt].Password := 'captain';

    Crpe1.LogOnInfo[cnt].DatabaseName := 'stats';

  end;

  Crpe1.Execute;

end;


DescriptiveName property

See also	Example

Applies to

LogOnInfo

Declaration

property DescriptiveName: string;

Description

DescriptiveName is a runtime, read-only property that contains descriptive information about the Table that the LogOnInfo item applies to.  It will only have a value if the Retrieve method was used.  The DLLName, and TableType properties also provide more details that describe the Table.

If the Report uses one of Crystal's native SQL drivers to connect to the Table, the DescriptiveName will be something like this:

Oracle7 SQL

Microsoft SQL Server

If the Report uses an ODBC driver to connect to the Table, the DescriptiveName will be the ODBC Data Source name with "ODBC - " prefixed to it:

ODBC - OracleTest

ODBC - Interbase


DescriptiveName property - See also
Related

DLLName

TableType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DescriptiveName property - Example
Example

The following code shows how to obtain the table description information from the LogOnInfo object:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ConnectMethod := useLogOnInfo;

  Crpe1.LogOnInfo.Retrieve;

  if Crpe1.LogOnInfo.Count > 0 then

  begin

    Edit1.Text := Crpe1.LogOnInfo[0].TableType;

    Edit2.Text := Crpe1.LogOnInfo[0].DescriptiveName;

    Edit3.Text := Crpe1.LogOnInfo[0].DLLName;

  end;

end;


DLLName property

See also	Example

Applies to

LogOnInfo

Declaration

property DLLName: string;

Description

DLLName is a runtime, read-only property that contains descriptive information about the Table that the LogOnInfo item applies to.  It will only have a value if the Retrieve method was used.  The DescriptiveName, and TableType properties also provide more details that describe the Table.

If the Report uses one of Crystal's native SQL drivers to connect to the Table, the DLLName will be something like this:

pdsora7.dll {Oracle}

pdssql.dll  {MS SQL Server}

If the Report uses an ODBC driver to connect to the Table, the DLLName will be:

pdsodbc.dll


DLLName property - See also
Related

DescriptiveName

TableType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DLLName property - Example
Example

The following code shows how to obtain the table description information from the LogOnInfo object:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ConnectMethod := useLogOnInfo;

  Crpe1.LogOnInfo.Retrieve;

  if Crpe1.LogOnInfo.Count > 0 then

  begin

    Edit1.Text := Crpe1.LogOnInfo[0].TableType;

    Edit2.Text := Crpe1.LogOnInfo[0].DescriptiveName;

    Edit3.Text := Crpe1.LogOnInfo[0].DLLName;

  end;

end;


Item property

See also	Example

Applies to

LogOnInfo

Declaration

property Item[const nIndex: integer]: TCrpeLogOnInfo;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the LogOnInfo object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  LogOnInfo[2] is the same as LogOnInfo.Item[2].

•	Item returns a reference to the LogOnInfo object, so the LogOnInfo properties can be used right after the subscript: LogOnInfo[2].DatabaseName := 'MyDatabase';


Item property - See also
Related

ItemIndex

Table

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.LogOnInfo.Retrieve;

{Set LogOnInfo to the 3rd Table}

Crpe1.LogOnInfo.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.LogOnInfo.Retrieve;

{Set LogOnInfo to the 3rd Table}

Crpe1.LogOnInfo[2];


ItemIndex property

See also	Example

Applies to

LogOnInfo

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current LogOnInfo item number, or set the LogOnInfo object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (LogOnInfo[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

Table

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the LogOnInfo object is pointing to the first LogOnInfo item:

if Crpe1.LogOnInfo.ItemIndex <> 0 then

  Crpe1.LogOnInfo[0];


Password property

See also	Example

Applies to

LogOnInfo

Declaration

property Password: string;

Description

The Password property contains the user password required for logging on to a SQL Server.  This is not stored in the Report when it is saved (and therefore will not be returned by the Retrieve method), but must be provided before running the Report.  Password is limited to 128 characters in length (anything greater than that will be truncated).


Password property - See also
Related

ServerName

UserID

DatabaseName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Password property - Example
Example

This example shows how to retrieve LogOn information and then set it for each item:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ConnectMethod := useLogOnInfo;

  Crpe1.LogOnInfo.Retrieve;

  for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do

  begin

    Crpe1.LogOnInfo[cnt].ServerName := 'Enterprise';

    Crpe1.LogOnInfo[cnt].UserID := 'Kirk';

    Crpe1.LogOnInfo[cnt].Password := 'captain';

    Crpe1.LogOnInfo[cnt].DatabaseName := 'stats';

  end;

  Crpe1.Execute;

end;


ServerName property

See also	Example

Applies to

LogOnInfo

Declaration

property ServerName: string;

Description

This property contains the name of the Server being connected to.  ServerName is limited to 128 characters in length (anything greater than that will be truncated).

•	If the Report was created using Crystal's native SQL drivers, this will be the actual Server name.

•	If the Report was created using ODBC drivers, this will be the ODBC Data Source Name.


ServerName property - See also
Related

UserID

Password

DatabaseName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ServerName property - Example
Example

This example shows how to retrieve LogOn information and then set it for each item:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ConnectMethod := useLogOnInfo;

  Crpe1.LogOnInfo.Retrieve;

  for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do

  begin

    Crpe1.LogOnInfo[cnt].ServerName := 'Enterprise';

    Crpe1.LogOnInfo[cnt].UserID := 'Kirk';

    Crpe1.LogOnInfo[cnt].Password := 'captain';

    Crpe1.LogOnInfo[cnt].DatabaseName := 'stats';

  end;

  Crpe1.Execute;

end;


Table property

See also	Example

Applies to

LogOnInfo

Declaration

property Table: TCrLogOnInfoTable;

Type

TCrLogOnInfoTable = integer;

Description

The Table property contains the number of the Table in the LogOnInfo item.  It uses a zero-based numbering scheme, so the first Table in a Report is number 0.  The Table property is the key lookup property for the LogOnInfo object and therefore cannot be changed by direct assignment.  For example:

Crpe1.LogOnInfo.Table := 2;

will cause the LogOnInfo object to look up and move to the item with a Table value of 2 (if the Retrieve method was used to fill LogOnInfo, this would normally be the 3rd item).  It will not overwrite the current Table property with a new Table number.


Table property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Table property - Example
Example

This example illustrates the use of the Table property.  Since the Retrieve method is used, we can be sure that the first item has a Table number of zero, the second item has a Table number of one, etc.:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ConnectMethod := useLogOnInfo;

  Crpe1.LogOnInfo.Retrieve;

  for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do

  begin

    {Set LogOnInfo to a specific item}

    Crpe1.LogOnInfo.Table := cnt;

    {Set the other properties for that item}

    Crpe1.LogOnInfo.ServerName := 'Enterprise';

    Crpe1.LogOnInfo.UserID := 'Kirk';

    Crpe1.LogOnInfo.Password := 'captain';

    Crpe1.LogOnInfo.DatabaseName := 'stats';

  end;

  Crpe1.Execute;

end;


TableType property

See also	Example

Applies to

LogOnInfo

Declaration

property TableType: TCrTableType;

Type

TCrTableType = (ttUnknown, ttStandard, ttSQL);

Description

TableType is a runtime, read-only property that contains descriptive information about the Table that the LogOnInfo item applies to.  It will only have a value if the Retrieve method was used.  The DLLName, and DescriptiveName properties also provide more details that describe the Table.

TableType will be one of the following:

ttSQL 	- The Table is an SQL-type table, or a Table being accessed via ODBC.

ttStandard 	- The Table is a PC-Type database (dBase, FoxPro, Access, Paradox, etc.) using native database connections (ie. not via ODBC).

ttUnknown 	- The TableType could not be identified.


TableType property - See also
Related

DescriptiveName

DLLName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TableType property - Example
Example

The following code shows how to obtain the table description information from the LogOnInfo object:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ConnectMethod := useLogOnInfo;

  Crpe1.LogOnInfo.Retrieve;

  if Crpe1.LogOnInfo.Count > 0 then

  begin

    Edit1.Text := Crpe1.LogOnInfo[0].TableType;

    Edit2.Text := Crpe1.LogOnInfo[0].DescriptiveName;

    Edit3.Text := Crpe1.LogOnInfo[0].DLLName;

  end;

end;


UserID property

See also	Example

Applies to

LogOnInfo

Declaration

property UserID: string;

Description

This property contains the user name required to log on to the SQL Server.  UserID is limited to 128 characters in length (anything greater than that will be truncated).


UserID property - See also
Related

ServerName

Password

DatabaseName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


UserID property - Example
Example

This example shows how to retrieve LogOn information and then set it for each item:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ConnectMethod := useLogOnInfo;

  Crpe1.LogOnInfo.Retrieve;

  for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do

  begin

    Crpe1.LogOnInfo[cnt].ServerName := 'Enterprise';

    Crpe1.LogOnInfo[cnt].UserID := 'Kirk';

    Crpe1.LogOnInfo[cnt].Password := 'captain';

    Crpe1.LogOnInfo[cnt].DatabaseName := 'stats';

  end;

  Crpe1.Execute;

end;


Create method

See also

Applies to

LogOnInfo

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

LogOnInfo

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

LogOnInfo

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the LogOnInfo object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.LogOnInfo.Retrieve;

  for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do

    Crpe1.LogOnInfo[cnt].Password := 'mytrickypassword';

end;


Retrieve method

See also	Example

Applies to

LogOnInfo

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the LogOnInfo information from the Report.  Retrieve will create one LogOnInfo item for each SQL table it finds in the Report.  If LogOn information was not found, the call returns False.  Be aware that calling Retrieve will first cause the LogOnInfo object to be cleared, so any current information stored in it will be removed.

Note

Since the LogOnInfo object also applies to Subreports, the Retrieve method will obtain the LogOnInfo for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the LogOnInfo settings for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate LogOnInfo settings for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.LogOnInfo.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.LogOnInfo.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

LogOnInfo

Declaration

function Send: TCrBoolean;

Description

The Send method sends the LogOnInfo values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that the ConnectMethod property is set to useLogOnInfo, and  SendOnExecute is set to True.  If the PromptForLogOn property is set to True, a LogOn dialog will appear on Execute, prompting for the LogOn parameters.

The function will return one of three values, cTrue, cFalse, cDefault:

cTrue	- If the PromptForLogOn property was set to False, a result of cTrue indicates that the LogOn parameters were passed to the Report successfully.  If the PromptForLogOn property was set to True, a result of cTrue indicates that the PromptDialog appeared, the Ok button on the dialog was pressed, and the LogOn parameters were passed successfully.

cFalse	- The PromptForLogOn property was set to True, the PromptDialog appeared, and the user either cancelled the dialog, or the LogOn parameters were not passed successfully.

cDefault	- The PromptForLogOn property was set to False, and the LogOn parameters were either not passed (if there were no LogOnInfo items), or passed unsuccessfully.

Note

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the LogOnInfo settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.LogOnInfo.Send;


Test method

See also	Example

Applies to

LogOnInfo

Declaration

function Test: boolean;

Description

The Test method provides a way to test the connection before running the Report.  With LogOnInfo, this can be done on a table by table basis, since the Test can be applied to each item.  Returns True if the connection was successful, False if it was not.


Test method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Test method - Example
Example

This example illustrates the use of the Test method:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useLogOnInfo;

Crpe1.LogOnInfo.Retrieve;

for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do

begin

  Crpe1.LogOnInfo[cnt].UserID := 'Maxwell Smart';

  Crpe1.LogOnInfo[cnt].Password := 'Agent86';

  if Crpe1.LogOnInfo.Test then

    ShowMessage('LogOn information is good: Table #' + IntToStr(Crpe1.LogOnInfo[cnt].Table))

  else

    ShowMessage('LogOn information is not good: Table #' + IntToStr(Crpe1.LogOnInfo[cnt].Table));

end;


Add method

See also	Example

Applies to

LogOnInfo

Declaration

function Add(TableNumber: TCrLogOnInfoTable): integer;

Type

TCrLogOnInfoTable = integer;

Description

The Add method adds an item to the LogOnInfo object and sets the LogOnInfo internal index to that item.  It requires a Table number as a parameter, which should be a number corresponding to a Table in the Report.  Tables are numbered starting from zero.  If the Add method is used, the steps to using LogOnInfo are:

1. Add an item to the LogOnInfo object (you must specify the Table number).

2. Fill the item's properties (ServerName, Password, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.  Test can be used beforehand to check the connection.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Table numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The following code illustrates the use of the Add and Delete methods to run a Report twice, each time with different LogOn information (it is assumed in the example that there is only one table in the Report):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useLogOnInfo;

with Crpe1.LogOnInfo do

begin

  Add(0);              {Add a LogOnInfo item, first Table}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

end;

Crpe1.Execute;

while not Crpe1.PrintEnded do

  Application.ProcessMessages;

Crpe1.LogOnInfo.Delete(0);

Crpe1.ConnectMethod := useLogOnInfo;

with Crpe1.LogOnInfo do

begin

  Add(0);              {Add a LogOnInfo item, first Table}

  ServerName := 'oracleserver2';

  UserID := 'JACOB';

  Password := 'zebra';

  DatabaseName := '';  {Not usually req'd for Oracle}

end;

{Make sure the data is not saved from the first Execute}

Crpe1.DiscardSavedData := True;

Crpe1.Execute;


Clear method

See also	Example

Applies to

LogOnInfo

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the LogOnInfo object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the LogOnInfo object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the LogOnInfo of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear:

for cnt := 0 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.LogOnInfo.Clear;

end;


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the LogOnInfo properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.LogOnInfo.Clear;

This code clears the LogOnInfo properties for the second Subreport:

Crpe1.Subreports[2];

Crpe1.LogOnInfo.Clear;


Delete method

See also	Example

Applies to

LogOnInfo

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the LogOnInfo object.  The "nIndex" parameter represents the number of the item in the LogOnInfo object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The following code illustrates the use of the Add and Delete methods to run a Report twice, each time with different LogOn information (it is assumed in the example that there is only one table in the Report):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useLogOnInfo;

with Crpe1.LogOnInfo do

begin

  Add(0);              {Add a LogOnInfo item, first Table}

  ServerName := 'oracleserver';

  UserID := 'SCOTT';

  Password := 'tiger';

  DatabaseName := '';  {Not usually req'd for Oracle}

end;

Crpe1.Execute;

while not Crpe1.PrintEnded do

  Application.ProcessMessages;

Crpe1.LogOnInfo.Delete(0);

with Crpe1.LogOnInfo do

begin

  Add(0);              {Add a LogOnInfo item, first Table}

  ServerName := 'oracleserver2';

  UserID := 'JACOB';

  Password := 'zebra';

  DatabaseName := '';  {Not usually req'd for Oracle}

end;

{Make sure the data is not saved from the first Execute}

Crpe1.DiscardSavedData := True;

Crpe1.Execute;


CopyFrom method

See also	Example

Applies to

LogOnInfo

Declaration

procedure CopyFrom(Source: TCrpeLogOnInfo);

Description

The CopyFrom method copies the LogOnInfo property values from another TCrpeLogOnInfo object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the LogOnInfo property values to a temporary TCrpeLogOnInfo object:

var

tempLogOnInfo : TCrpeLogOnInfo;

begin

tempLogOnInfo := TCrpeLogOnInfo.Create;

tempLogOnInfo.CopyFrom(Crpe1.LogOnInfo);

{...later, when finished with the temp object...}

tempLogOnInfo.Free;

end;


PromptForLogOn property

See also	Example

Applies to

LogOnInfo

Declaration

property PromptForLogOn: Boolean;

Description

The PromptForLogOn property determines whether the VCL will create a LogOn dialog to obtain the log on parameters required to run a Report based on SQL tables or ODBC datasources.  If PromptForLogOn is set to True, and LogOnInfo.Send, or Crpe1.Execute is called, the VCL will present a LogOn dialog that looks like this:

The Connections listbox on the dialog contains a list of all unique connections required in the Report (including Subreports).  The other edit fields (ServerName, UserID, Password, and DatabaseName) hold the required log on information.  These can be edited.  If the OK button is pressed, the log on information from the edit fields is applied to the various tables in the Report, and the Report is run.  If the Cancel button is pressed, the execution of the Report stops.

If you would like the Prompt dialog to contain different Server information than what is stored in the Report, follow these steps:

1. Retrieve LogOnInfo from the Report.

2. Set PromptForLogOn to False.

3. Modify the LogOnInfo property values to the desired settings.

4. Call LogOnInfo.Send to send these parameters into the Report.

5. Repeat steps 1 to 4 for any Subreports.

6. Set PromptForLogOn to True.

7. Call Crpe1.Execute.

Note

If you wish to modify this dialog, the Form information is stored in URLOGON.DFM.  The URLOGON.PAS file is in the Source\Dialogs directory, although if changes are made to the URLOGON.PAS, they must be copied into the appropriate section of the UCDIALOG.PAS file in order to be compiled into the VCL.


PromptForLogOn property - See also
Related

Send

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PromptForLogOn property - Example
Example

The following example shows how to use the PromptForLogOn property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useLogOnInfo;

Crpe1.LogOnInfo.PromptForLogOn := True;

Crpe1.Output := toWindow;

{LogOn Prompt Dialog appears after Execute}

Crpe1.Execute;


SQLTablesOnly property

See also	Example

Applies to

LogOnInfo

Declaration

property SQLTablesOnly: Boolean;

Description

The SQLTablesOnly property determines whether the LogOnInfo object will only retrieve SQL tables, or whether it will retrieve all tables, SQL or PC type.  Probably the only reason for retrieving non-SQL tables is to set the Password property for password-protected Paradox tables, which can be done in the Tables.Password property already.  However, for the sake of completeness, the option is included.

The default setting for SQLTablesOnly is True.


SQLTablesOnly property - See also
Related

Tables.Password

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SQLTablesOnly property - Example
Example

The following example shows how to use the SQLTablesOnly property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useLogOnInfo;

Crpe1.LogOnInfo.SQLTablesOnly := False;

Crpe1.LogOnInfo.Retrieve;

for i := 0 to Crpe1.LogOnInfo.Count - 1 do

  Crpe1.LogOnInfo[i].Password := 'SecretAgent';

Crpe1.Output := toWindow;

Crpe1.Execute;


Tables

See also	Properties & Methods	Example

Declaration

property Tables: TCrpeTables;

Types

TCrpeTables = class(TPersistent)

Description

The Tables object maintains a list of Table information.  There are four general types of tables:

1. Native PC-type databases such as dBase, FoxPro, or Paradox, in which the Table Name is usually the same as the actual filename, and the Path is the actual DOS directory to the file.  In these cases, the Name property can be used to change which Table is being used by the Report, the Path property can be used to change the directory in which the Table is located, and the Propagate property can be used to set all Tables to the same directory.  The Password property applies to Paradox password-protected Tables.

2. Native PC-type databases such as Access, where the Tables are stored inside a Database file.  In these cases, the Name property represents the Database (or Access MDB file), the SubName property represents the actual Table contained inside the Database, and the Path is the directory to the Database, not to the individual Table.  It is possible to use the Tables object to change to a different MDB file, but it is not possible to change to a different Table within the same MDB.  That must be done within the Crystal Reports Designer.  For Access Password-protected Tables, use the SessionInfo object instead of the Password property of the Tables object.

3. SQL-type tables such as Oracle, Sybase, Informix, MS SQL Server, or ODBC Datasources.  In these cases, Path and Propagate are not used.  The Name property contains the name of the Table (and sometimes Database or User names as well) and can be used to point the Report to a different Table within the currently logged on Server.

4. ActiveData datasources such as Crystal Data Object, MS ActiveX Data Object, etc.  Reports going to these types of datasources do not point to a physical table.  They point to a Field Definition File (*.TTX), which is a text file that defines the Field types and sizes of the virtual table.  The data is then passed into such a Report at runtime by an Active Data object.  This bypasses the need of having Crystal's runtime engine open a separate connection to the database.  The Name property of the Tables class will contain the name of the TTX file that the Report was based on.  This cannot be changed at runtime.  For ActiveData sources, use the DataPointer property to point to the new datasource.  The Tag and Bytes properties are associated with ActiveData Reports and should be treated as read-only (they are handled by the VCL internally).

•	The TableType, DLLName, and DescriptiveName properties are read-only properties which  contain descriptive information about the Table, and are filled with values when the Retrieve method is used.

•	The ItemIndex property or the default array property, Item, can be used to navigate through the Tables.

•	The Count method returns the number of Tables in the current Report.

•	The Clear method can be used to clear the Tables object of all information, although this is normally handled automatically in the VCL whenever the ReportName is changed.

•	The Add and Delete properties are manual methods of maintaining the Tables object internal lists, and are not needed if the Retrieve method is used.

•	The Test and CheckDifferences methods can be used to analyze the Tables before the Report runs.


Tables - See also
Related

Connect

LogOnInfo

SessionInfo

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Tables - Properties & Methods
Tables:

Properties & Methods

Tables	TCrpe Component

Properties

ConnectBuffer

Name

Password

Path

Propagate

SubName

Key

Number

Table Information

DescriptiveName

DLLName

TableType

Navigation

Item

ItemIndex

ActiveData

Bytes

DataPointer

Tag

Methods

Clear

CopyFrom

Count

IndexOf

IndexOfName

Retrieve

Send

Testing

Test

CheckDifferences

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


Tables - Example
Example

In this example, the Tables are retrieved, and then a loop is set up to change the Path for all the tables:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Retrieve;

for cnt := 0 to (Crpe1.Tables.Count - 1) do

  Crpe1.Tables[cnt].Path := 'c:\MyNewPath\';

Crpe1.Execute;

In the above scenario, the Propagate property could also be used, so that it would only be necessary to set the path for the first table:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Retrieve;

Crpe1.Tables[0].Path := 'c:\MyNewPath\';

Crpe1.Tables.Propagate := True;

Crpe1.Execute;


DescriptiveName property

See also	Example

Applies to

Tables

Declaration

property DescriptiveName: string;

Description

DescriptiveName is a read-only, run-time property which contains a description of the database driver being used by Crystal Reports to connect to the Table, for example:

xBase

IDAPI Database DLL

Oracle7 SQL

ODBC - Interbase

This property goes along with TableType and DLLName to provide a complete description of the database driver.  These properties will only have values after the Retrieve method is called.


DescriptiveName property - See also
Related

DLLName

TableType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DescriptiveName property - Example
Example

The following example illustrates the use of the DescriptiveName property:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Tables}

Crpe1.Tables.Retrieve;

{Loop through Tables obtaining descriptive information}

for cnt := 0 to (Crpe1.Tables.Count - 1) do

begin

  ListBox1.Items.Add(Crpe1.Tables[cnt].TableType);

  ListBox2.Items.Add(Crpe1.Tables[cnt].DLLName);

  ListBox3.Items.Add(Crpe1.Tables[cnt].DescriptiveName);

end;


DLLName property

See also	Example

Applies to

Tables

Declaration

property DLLName: string;

Description

DLLName is a read-only, run-time property which contains the name of the database driver being used by Crystal Reports to connect to the Table, for example:

pdbxbse.dll

pdbbde.dll

pdsora7.dll

pdsodbc.dll

pdsmon.dll

Note

The 16-bit naming convention is used, even though the DLL's may be 32-bit (P2BXBSE.DLL, etc.).  This property goes along with TableType and DescriptiveName to provide a complete description of the database driver.  These properties will only have values after the Retrieve method is called.


DLLName property - See also
Related

DescriptiveName

TableType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DLLName property - Example
Example

The following example illustrates the use of the DLLName property:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Tables}

Crpe1.Tables.Retrieve;

{Loop through Tables obtaining descriptive information}

for cnt := 0 to (Crpe1.Tables.Count - 1) do

begin

  ListBox1.Items.Add(Crpe1.Tables[cnt].TableType);

  ListBox2.Items.Add(Crpe1.Tables[cnt].DLLName);

  ListBox3.Items.Add(Crpe1.Tables[cnt].DescriptiveName);

end;


Item property

See also	Example

Applies to

Tables

Declaration

property Item[const nIndex: integer]: TCrpeTables;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the Tables object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  Tables[2] is the same as Tables.Item[2].

•	Item returns a reference to the Tables object, so the Tables properties can be used right after the subscript: Tables[2].Name := 'MyTable.dbf';


Item property - See also
Related

ItemIndex

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Retrieve;

{Set Tables object to the 3rd item}

Crpe1.Tables.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Retrieve;

{Set Tables object to the 3rd item}

Crpe1.Tables[2];


ItemIndex property

See also	Example

Applies to

Tables

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current Tables item number, or set the Tables object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (Tables[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the Tables object is pointing to the first Table:

if Crpe1.Tables.ItemIndex <> 0 then

  Crpe1.Tables[0];


Name property

See also	Example

Applies to

Tables

Declaration

property Name: string;

Description

The Name property is the table name of the current Table, without the path.  Note that the length of the Path plus the Name should not exceed 256 characters (anything greater than that will be truncated).

Database Location Examples

Different database types have different ways of specifying a Table.  Here are a few examples.  Note that ODBC and SQL databases do not use a drive path, and therefore, their location is specified in the Name property only, instead of Path and Name.

xBASE (Natively)	: <drive>:\<path>\<file>

xBASE (ODBC)	: <datasource name>

Paradox (Natively)	: <drive>:\<path>\<file>

Paradox (ODBC)	: <datasource name>

Btrieve (Natively)	: <drive>:\<path>\<file>

Btrieve (ODBC)	: <datasource name>

Oracle (Natively)	: <database>.<table>

Oracle (ODBC)	: <database>.<table>

SQL Server (Natively)	: <database>.<owner>.<table>

SQL Server (ODBC)	: <database>.<owner>.<table>


Name property - See also
Related

Path

SubName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Name property - Example
Example

The following example shows how to change the name of a Table:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Tables.Retrieve;

  for cnt := 0 to (Crpe1.Tables.Count - 1) do

    Crpe1.Tables[cnt].Name := 'MyNewName.dbf';

end;


Number property

See also	Example

Applies to

Tables

Declaration

property Number: TCrTableNumber;

Type

TCrTableNumber = integer;

Description

The Number property contains the number of the Table in the Report.  It uses a zero-based numbering scheme, so the first Table in a Report is number 0.  The Number property is the key lookup property for the Tables object and therefore cannot be changed by direct assignment.  For example:

Crpe1.Tables.Number := 2;

will cause the Tables object to look up and move to the second table in the Report.  It will not overwrite the current Table with a new Table number.


Number property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

This example demonstrates the use of the Number property to point to a specific Table:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Retrieve;

{Go to Table number 2}

Crpe1.Tables.Number := 2;

{Change the Path for that Table}

Crpe1.Tables.Path := 'C:\NewPath\';

Crpe1.Execute;


Password property

See also	Example

Applies to

Tables

Declaration

property Password: string;

Description

The Password property applies to Paradox password-protected tables.  For MS Access password-protected Tables, use the SessionInfo object instead of the Password property of the Tables object.  Password is limited to 128 characters in length (anything greater than that will be truncated).


Password property - See also
Related

SessionInfo

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Password property - Example
Example

The code below shows how to use the Password property of the Tables object:

Crpe1.ReportName := 'C:\ParadoxTable.rpt';

Crpe1.Tables.Retrieve;

Crpe1.Tables[0].Password := 'SwornToSecrecy';

Crpe1.Execute;


Path property

See also	Example

Applies to

Tables

Declaration

property Path: string;

Description

The Path property is the path of the current Table.  If the current table is:

'c:\mydir\table1.dbf'

the Path would be:

'c:\mydir\'

A BDE Alias can also be passed to this property to assign the Table a new path:

Crpe1.Tables.Path := ':MyAlias:';

The Propagate property causes the Path of the first Table to be used for all the Tables in the main Report and all Subreports as well.  If Propagate is set to True on a Tables object that belongs to a Subreport, then only the Tables of that Subreport will use the same path as the first Table of the main Report.

Note that Retrieve or Add have to be called first to fill the Tables object with Table items.

The length of the Path plus the Name should not exceed 256 characters (anything greater than that will be truncated).

Database Location Examples

Different database types have different ways of specifying a Table.  Here are a few examples.  Note that ODBC and SQL databases do not use a drive path, and therefore, their location is specified in the Name property only, instead of Path and Name.

xBASE (Natively)	: <drive>:\<path>\<file>

xBASE (ODBC)	: <datasource name>

Paradox (Natively)	: <drive>:\<path>\<file>

Paradox (ODBC)	: <datasource name>

Btrieve (Natively)	: <drive>:\<path>\<file>

Btrieve (ODBC)	: <datasource name>

Oracle (Natively)	: <database>.<table>

Oracle (ODBC)	: <database>.<table>

SQL Server (Natively)	: <database>.<owner>.<table>

SQL Server (ODBC)	: <database>.<owner>.<table>


Path property - See also
Related

Name

GetPathFromAlias

SubName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Path property - Example
Example

The following code changes the Path of the second Table:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Tables.Retrieve;

Crpe1.Tables[1].Path := 'c:\MyNewDir\';

Crpe1.Execute;

The following code changes the Path of the first Table to a BDE Alias called 'MyAlias':

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Tables.Retrieve;

Crpe1.Tables[0].Path := ':MyAlias:';

Crpe1.Execute;

The following code changes the Path of the first Table and causes the change to be used for all the Tables in the main Report and any Subreports:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Tables.Retrieve;

Crpe1.Tables[0].Path := 'C:\MyNewDir\';

Crpe1.Tables.Propagate := True;

Crpe1.Execute;

The following code loops through all Tables in the first Subreport and changes the paths:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Subreports.Retrieve;

Crpe1.Subreports[1];

Crpe1.Tables.Retrieve;

for cnt := 0 to (Crpe1.Tables.Count - 1) do

  Crpe1.Tables[cnt].Path := 'c:\MyNewDir\';


Propagate property

See also	Example

Applies to

Tables

Declaration

property Propagate: boolean;

Description

In the previous versions of the Crystal VCL, there was a property called "DatafilesLocation" which allowed the programmer to pass in a directory path that would be used for all the Tables in the Report, including any Subreports.  This functionality has been included in the Tables object by the inclusion of the Propagate property.

If this property is set to True, then the path of the first Table in the main Report will be used for the paths of all other Tables.  If the Propagate property of the Tables object is set to True for a Subreport, then that Subreport will use the path from the first Table of the main Report for all of the paths of it's Tables.  This will not affect the Table paths of the other Subreports.  Setting the Propagate flag in the main Report, however, will affect the Table paths in all the Subreports (see the Example).


Propagate property - See also
Related

Path

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Propagate property - Example
Example

If the Propagate property is set to True for the main Report, then the path of the first Table in the main Report will be used for the paths of all other Tables in the main Report, and any Subreports also:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Tables.Retrieve;

{Set Path of first Table}

Crpe1.Tables[0].Path := 'c:\MyNewPath\';

Crpe1.Tables.Propagate := True;

If the Propagate property of a Subreport Tables object is set to True, then the Tables for that Subreport will use the path from the first Table of the main Report for all of their paths:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Tables.Retrieve;

{Sets VCL to Subreport 1}

Crpe1.Subreports[1];

{Sets Propagate flag for Subreport 1 Tables}

Crpe1.Tables.Propagate := True;

In the above example, setting the Propagate flag for a Subreport, will cause that Subreport to get it's Table Path information from the first Table in the main Report.  It will not affect the Table Paths of the other Subreports.  Setting the Propagate flag in the main Report, however, will affect the Tables in all the Subreports.


TableType property

See also	Example

Applies to

Tables

Declaration

property TableType: TCrTableType;

Type

TCrTableType = (ttUnknown, ttStandard, ttSQL);

Description

TableType is a read-only, run-time property which contains the type of the database driver being used by Crystal Reports to connect to the Table.  TableType will be one of the following:

ttSQL 	- The Table is an SQL-type table, or a Table being accessed via ODBC.

ttStandard 	- The Table is a PC-Type database (dBase, FoxPro, Access, Paradox, etc.) using native database connections (ie. not via ODBC).

ttUnknown 	- The TableType could not be identified.

This property goes along with DLLName and DescriptiveName to provide a complete description of the database driver.  These properties will only have values after the Retrieve method is called.


TableType property - See also
Related

DescriptiveName

DLLName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TableType property - Example
Example

The following example illustrates the use of the TableType property:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Tables}

Crpe1.Tables.Retrieve;

{Loop through Tables obtaining descriptive information}

for cnt := 0 to (Crpe1.Tables.Count - 1) do

begin

  ListBox1.Items.Add(Crpe1.Tables[cnt].TableType);

  ListBox2.Items.Add(Crpe1.Tables[cnt].DLLName);

  ListBox3.Items.Add(Crpe1.Tables[cnt].DescriptiveName);

end;


Create method

See also

Applies to

Tables

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Tables object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

Tables

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

Tables

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the Tables object.  It is useful for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Tables.Retrieve;

  for cnt := 0 to (Crpe1.Tables.Count - 1) do

    Crpe1.Tables[cnt].Name := 'NewTable.dbf';

end;


Retrieve method

See also	Example

Applies to

Tables

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Tables information from the Report and adds one item to the Tables object for each Table in the Report.  If Tables information was not found, the call returns False.  Be aware that calling Retrieve will first cause the Tables object to be cleared, so any current information stored in it will be removed.

Note

Since the Tables object also applies to Subreports, the Retrieve method will obtain the Tables for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the Tables information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate Tables information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.Tables.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

Tables

Declaration

function Send: boolean;

Description

The Send method sends the Tables values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the Tables settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.Tables.Send;


Add method

See also	Example

Applies to

Tables

Declaration

function Add(TableNumber: TCrTableNumber): integer;

Type

TCrTableNumber = integer;

Description

The Add method adds an item to the Tables object and sets the internal index to that item.  It requires a Table number as a parameter, which should be a number corresponding to a Table in the Report.  Tables are numbered starting from zero.  If the Add method is used, the steps to using Tables are:

1. Add an item to the Tables object (you must specify the Table number).

2. Fill the item's properties (Name, Path, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Table numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The following code uses the Add method to set the values for the first table in a Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Add(0);

Crpe1.Tables[0].Name := 'Address.dbf';

Crpe1.Tables[0].Path := 'C:\Temp\Tables\';

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

Tables

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the Tables object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the Tables object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the Tables of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear:

for cnt := 0 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.Tables.Clear;

end;


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the Tables properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.Tables.Clear;

This code clears the Tables properties for the second Subreport:

Crpe1.Subreports[2];

Crpe1.Tables.Clear;


Delete method

See also	Example

Applies to

Tables

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the Tables object.  The "nIndex" parameter represents the number of the item in the Tables object, which may not be the same as the actual Table Number.

Note

Delete will not remove the Table from the Report, it will just remove it from the Crystal VCL.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The following code uses the Add method to set the values for the first table in a Report, and then, after running the Report, deletes the Table item from the VCL.  This is not normally necessary, though, as Tables would automatically be cleared when the ReportName changes:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Add(0);

Crpe1.Tables[0].Name := 'Address.dbf';

Crpe1.Tables[0].Path := 'C:\Temp\Tables\';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.Tables.Delete(0);


CopyFrom method

See also	Example

Applies to

Tables

Declaration

procedure CopyFrom(Source: TCrpeTables);

Description

The CopyFrom method copies the Tables property values from another TCrpeTables object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Tables property values to a temporary TCrpeTables object:

var

tempTables : TCrpeTables;

begin

tempTables := TCrpeTables.Create;

tempTables.CopyFrom(Crpe1.Tables);

{...later, when finished with the temp object...}

tempTables.Free;

end;


Bytes property

See also	Example

Applies to

Tables

Declaration

property Bytes: smallint;

Description

The Bytes property, along with the Tag and DataPointer properties are part of the ADO/CDO support that has been added to the Tables class with the 7.x.0.20 release of the Crystal Reports VCL.   DataPointer is the only property that is required to be set.  The Bytes property does not need to be set by the programmer.  It will be retrieved from the Report.


Bytes property - See also
Related

DataPointer

Tag

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Bytes property - Example
Example

CDO Example

When using COM Objects in Delphi 3 or 4, the first thing that should always be done is to import the Type Library for the object.  This makes working with the object much easier, since a Pascal header file is automatically constructed.  To import the type library go to the Project menu in Delphi and select Import Type Library...

From the dialog that appears, the Crystal Data Object should be visible.

Select it and a header file for the object will be built in the Delphi\Imports directory, most likely with a name like: "CrystalDataObject_TLB.pas".  The header file name should be added to the uses clause of your Delphi Form source code.  Be sure to add the ComObj unit as well:

uses

  ComObj, CrystalDataObject_TLB, ...

Then the Crystal Data Object will need to be created in code.  In this example, two Memo controls are placed on a Form.  The Memo controls will be read into the Crystal Data Object, which will then pass the data to two fields in the Report (we are assuming that both Memos have the same number of lines of data):

var

  frmMain      : TfrmMain;

  CdoRecordset : CrystalComObject; {defined in CrystalDataObject_TLB}

implementation

procedure RunReport;

var

  iRows : integer;

  cnt   : integer;

  Rows  : OleVariant;

begin

  {Create the Crystal Data Object}

  CDORecordSet := CreateOleObject('CrystalDataObject.CrystalComObject') as CrystalComObject;

  {Add the Fields to the CDO}

  CdoRecordSet.AddField('Col1', '');

  CdoRecordSet.AddField('Col2', '');

  {Create a Variant Array for the Data}

  iRows := Memo1.Lines.Count;

  Rows := VarArrayCreate([0,iRows-1,0,1], varVariant);

  {Fill the Variant Array from the Memos}

  for cnt := 0 to Memo1.Lines.Count - 1 do

  begin

    Rows[cnt,0] := Memo1.Lines[cnt];

    Rows[cnt,1] := Memo2.Lines[cnt];

  end;

  {Add the Variant Array to the CDO}

  CDORecordSet.AddRows(VarArrayRef(Rows));

  {Load and Run the Report}

  Crpe1.ReportName := 'C:\2Cols.rpt';

  Crpe1.DiscardSavedData := True;

  Crpe1.Tables.Retrieve;

  {Attach the CDO Recordset to the Report}

  Crpe1.Tables[0].DataPointer := @CdoRecordset;

  Crpe1.Execute;

end;


Tag property

See also	Example

Applies to

Tables

Declaration

property Tag: DWord;

Description

The Tag property, along with the Bytes and DataPointer properties are part of the ADO/CDO support that has been added to the Tables class with the 7.x.0.20 release of the Crystal Reports VCL.  DataPointer is the only property that is required to be set.

Tag indicates the type of data being passed to the DataPointer property. Currently, the only possible value is 3 (although when retrieving the Tables information from an ActiveData Report, the value will usually be 2). This value (3) is used for all Active data sources including DAO, ADO, RDO, CDO.  It is set automatically in the VCL and does not need to be specified in code.


Tag property - See also
Related

Bytes

DataPointer

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Tag property - Example
Example

CDO Example

When using COM Objects in Delphi 3 or 4, the first thing that should always be done is to import the Type Library for the object.  This makes working with the object much easier, since a Pascal header file is automatically constructed.  To import the type library go to the Project menu in Delphi and select Import Type Library...

From the dialog that appears, the Crystal Data Object should be visible.

Select it and a header file for the object will be built in the Delphi\Imports directory, most likely with a name like: "CrystalDataObject_TLB.pas".  The header file name should be added to the uses clause of your Delphi Form source code.  Be sure to add the ComObj unit as well:

uses

  ComObj, CrystalDataObject_TLB, ...

Then the Crystal Data Object will need to be created in code.  In this example, two Memo controls are placed on a Form.  The Memo controls will be read into the Crystal Data Object, which will then pass the data to two fields in the Report (we are assuming that both Memos have the same number of lines of data):

var

  frmMain      : TfrmMain;

  CdoRecordset : CrystalComObject; {defined in CrystalDataObject_TLB}

implementation

procedure RunReport;

var

  iRows : integer;

  cnt   : integer;

  Rows  : OleVariant;

begin

  {Create the Crystal Data Object}

  CDORecordSet := CreateOleObject('CrystalDataObject.CrystalComObject') as CrystalComObject;

  {Add the Fields to the CDO}

  CdoRecordSet.AddField('Col1', '');

  CdoRecordSet.AddField('Col2', '');

  {Create a Variant Array for the Data}

  iRows := Memo1.Lines.Count;

  Rows := VarArrayCreate([0,iRows-1,0,1], varVariant);

  {Fill the Variant Array from the Memos}

  for cnt := 0 to Memo1.Lines.Count - 1 do

  begin

    Rows[cnt,0] := Memo1.Lines[cnt];

    Rows[cnt,1] := Memo2.Lines[cnt];

  end;

  {Add the Variant Array to the CDO}

  CDORecordSet.AddRows(VarArrayRef(Rows));

  {Load and Run the Report}

  Crpe1.ReportName := 'C:\2Cols.rpt';

  Crpe1.DiscardSavedData := True;

  Crpe1.Tables.Retrieve;

  {Attach the CDO Recordset to the Report}

  Crpe1.Tables[0].DataPointer := @CdoRecordset;

  Crpe1.Execute;

end;


DataPointer property

See also	Example

Applies to

Tables

Declaration

property DataPointer: Pointer;

Description

The DataPointer property, along with the Bytes and Tag properties are part of the ADO/CDO support that has been added to the Tables class with the 7.x.0.20 release of the Crystal Reports VCL.  DataPointer should point to the address of a valid Data Object RecordSet, such as an Active Data Object (ADO) RecordSet, or the Crystal Data Object (CDO) RecordSet.

There are two ways of using Data Objects in Delphi.  The first, easiest, and recommended way is to import the Type Library and use the Delphi-generated header file for all declarations.  This method is described and illustrated in the following two pages:

The Crystal Data Object (CDO)

The Active Data Object (ADO)

The other method is to use OleVariant variables instead of the declarations contained in the Type Library.  This involves one extra layer of communication and requires an extra line of code to obtain the actual address of the RecordSet to pass to the DataPointer property.  This method is illustrated below:

uses

  ComObj...

var

   Form1        : TForm1;

   CDORecordSet : OleVariant;

   Rows         : OleVariant;

   ITemp        : IDispatch;

implementation

procedure RunCDOReport;

begin

  { Create the Crystal DataObject }

  CDORecordSet := CreateOleObject('CrystalDataObject.CrystalComObject');

  { Add Fields to the CDORecordSet }

  CDORecordSet.AddField('ID');

  CDORecordSet.AddField('NameF');

  CDORowSet.AddField('NameL');

  { Create an OleVariant Array and add data to it }

  Rows := VarArrayCreate([0,2,0,2], varVariant); {rows, cols}

  Rows[0,0] := 1;

  Rows[0,1] := 'John';

  Rows[0,2] := 'Doe';

  Rows[1,0] := 2;

  Rows[1,1] := 'Bill';

  Rows[1,2] := 'Smith';

  Rows[2,0] := 3;

  Rows[2,1] := 'Henry';

  Rows[2,2] := 'Jones';

  { Add the Variant Array to to CDORecordSet }

  CDORecordSet.AddRows(VarArrayRef(Rows));

  { This line is necessary because of the extra layer imposed

   by declaring the CDORecordSet as OleVariant.}

  ITemp := IDispatch(TVarData(CDORecordSet).VDispatch);

  {Load and Run the Report}

  Crpe1.ReportName := 'C:\CDO.rpt';

  Crpe1.DiscardSavedData := True;

  Crpe1.Tables.Retrieve;

  {Attach the CDO RecordSet to the Report}

  Crpe1.Tables[0].DataPointer := @ITemp;

  Crpe1.Execute;

end;


DataPointer property - See also
Related

The Active Data Object (ADO)

The Crystal Data Object (CDO)

Bytes

Tag

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DataPointer property - Example
Example

CDO Example

When using COM Objects in Delphi 3 or 4, the first thing that should always be done is to import the Type Library for the object.  This makes working with the object much easier, since a Pascal header file is automatically constructed.  To import the type library go to the Project menu in Delphi and select Import Type Library...

From the dialog that appears, the Crystal Data Object should be visible.

Select it and a header file for the object will be built in the Delphi\Imports directory, most likely with a name like: "CrystalDataObject_TLB.pas".  The header file name should be added to the uses clause of your Delphi Form source code.  Be sure to add the ComObj unit as well:

uses

  ComObj, CrystalDataObject_TLB, ...

Then the Crystal Data Object will need to be created in code.  In this example, two Memo controls are placed on a Form.  The Memo controls will be read into the Crystal Data Object, which will then pass the data to two fields in the Report (we are assuming that both Memos have the same number of lines of data):

var

  frmMain      : TfrmMain;

  CdoRecordset : CrystalComObject; {defined in CrystalDataObject_TLB}

implementation

procedure RunReport;

var

  iRows : integer;

  cnt   : integer;

  Rows  : OleVariant;

begin

  {Create the Crystal Data Object}

  CDORecordSet := CreateOleObject('CrystalDataObject.CrystalComObject') as CrystalComObject;

  {Add the Fields to the CDO}

  CdoRecordSet.AddField('Col1', '');

  CdoRecordSet.AddField('Col2', '');

  {Create a Variant Array for the Data}

  iRows := Memo1.Lines.Count;

  Rows := VarArrayCreate([0,iRows-1,0,1], varVariant);

  {Fill the Variant Array from the Memos}

  for cnt := 0 to Memo1.Lines.Count - 1 do

  begin

    Rows[cnt,0] := Memo1.Lines[cnt];

    Rows[cnt,1] := Memo2.Lines[cnt];

  end;

  {Add the Variant Array to the CDO}

  CDORecordSet.AddRows(VarArrayRef(Rows));

  {Load and Run the Report}

  Crpe1.ReportName := 'C:\2Cols.rpt';

  Crpe1.DiscardSavedData := True;

  Crpe1.Tables.Retrieve;

  {Attach the CDO Recordset to the Report}

  Crpe1.Tables[0].DataPointer := @CdoRecordset;

  Crpe1.Execute;

end;


The Crystal Data Object (CDO)

See also

What is the Crystal Data Object (CDO)?

From the Seagate Crystal Reports Developers Help:

"The Crystal Data Object (CDO) is an ActiveX data source that allows you to define fields and records at runtime based on data that exists only at runtime. Through CDO, any data can become a virtual database and can be reported on using the power of the Crystal Report Engine."

"CDO, like DAO and ADO, is based on the Component Object Model (COM). Any development environment that supports COM interfaces can dynamically generate a set of data for a report without relying on a database that exists at design time. Applications that produce data that does not exist outside of the running application have been unable, until now, to take advantage of the most powerful reporting features in the industry. CDO, however, solves that problem. For instance, applications that monitor system or network resources, or any constantly operating environment, can produce a current report on such information at any time. No longer does data need to be dumped to a separate database before analysis. Through CDO, analysis is instant and up-to-date."

How do I use CDO in my Delphi Application?:

In brief, you need to create a CDO object, fill it with data, and then connect it to the Crystal Report.  The Report must be designed using the ActiveData datasource option.  This involves defining a TTX file (Field Definition File) which is a simple text file that specifies the database structure (Field Names, Types, and Lengths).  The actual Field Names specified in the file are not so important, but the Field types and the order in which they are specified, must match the type and order of the Field Columns that are created in the Crystal Data Object in order for the data to display properly at runtime.

When using COM Objects in Delphi 3 or 4, the first thing that should always be done is to import the Type Library for the object.  This makes working with the object much easier, since a Pascal header file is automatically constructed.  To import the type library go to the Project menu in Delphi and select Import Type Library...

From the dialog that appears, the Crystal Data Object should be visible.

Select it and a header file for the object will be built in the Delphi\Imports directory, most likely with a name like: "CrystalDataObject_TLB.pas".  The header file name should be added to the uses clause of your Delphi Form source code.  Be sure to add the ComObj unit as well:

uses

  Windows, Classes, Forms, ComObj, CrystalDataObject_TLB, ...

Then the Crystal Data Object will need to be created in code.  In this example, two Memo controls are placed on a Form.  The Memo controls will be read into the Crystal Data Object, which will then pass the data to two fields in the Report (we are assuming that both Memos have the same number of lines of data):

var

  frmMain   : TfrmMain;

  CdoRowset : CrystalComObject; {defined in CrystalDataObject_TLB}

implementation

procedure RunReport;

var

  iRows : integer;

  cnt   : integer;

  Rows  : OleVariant;

begin

  {Create the Crystal Data Object}

  CDORowSet := CreateOleObject('CrystalDataObject.CrystalComObject') as CrystalComObject;

  {Add the Fields to the CDO}

  CdoRowSet.AddField('Col1', '');

  CdoRowSet.AddField('Col2', '');

  {Create a Variant Array for the Data}

  iRows := Memo1.Lines.Count;

  Rows := VarArrayCreate([0,iRows-1,0,1], varVariant);

  {Fill the Variant Array from the Memos}

  for cnt := 0 to Memo1.Lines.Count - 1 do

  begin

    Rows[cnt,0] := Memo1.Lines[cnt];

    Rows[cnt,1] := Memo2.Lines[cnt];

  end;

  {Add the Variant Array to the CDO}

  CDORowSet.AddRows(VarArrayRef(Rows));

  {Load and Run the Report}

  Crpe1.ReportName := 'C:\2Cols.rpt';

  Crpe1.DiscardSavedData := True;

  Crpe1.Tables.Retrieve;

  {Attach the CDO Rowset to the Report}

  Crpe1.Tables[0].DataPointer := @CdoRowset;

  Crpe1.Execute;

end;


The Crystal Data Object (CDO) - See also
Related

Crystal Data Object Header

The Active Data Object (ADO)

DataPointer

Bytes

Tag

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


The Active Data Object (ADO)

See also

What is an Active Data Object (ADO)?

From the Seagate Crystal Reports Developers Help:

"ActiveX Data Objects (ADO) and OLEDB are Microsoft's new data connection technologies designed to provide a common interface for working with relational databases, mail messaging, event logs, and most any form of data storage. In addition, ADO provides a method of working with data that is easier and faster than previous technologies such as DAO and RDO. For more information on ADO, refer to Microsoft documentation."

"ADO can be used to connect to any ODBC or OLE DB compliant data source when you design your report in the Report Designer Component. The resulting ADO Recordset is not directly available from the Report Designer Component, but it can be replaced by alternative Recordset objects. For example, if your application allows users to make choices that can affect the set of data displayed by a report, simply create a new ADO Recordset at runtime, then pass it to the Report using the Tables.DataPointer property. The only restriction is that the fields in the new Recordset match the fields originally used to design the report."

How do I use ADO in my Delphi Application?:

In brief, you need to create an ADO object, fill it with data, and then connect it to the Crystal Report.  The Report must be designed using the ActiveData datasource option.  This involves defining a TTX file (Field Definition File) which is a simple text file that specifies the database structure (Field Names, Types, and Lengths).  The actual Field Names specified in the file are not so important, but the Field types and the order in which they are specified, must match the type and order of the Field Columns that are created in the Active Data Object in order for the data to display properly at runtime.

When using COM Objects in Delphi 3 or 4, the first thing that should always be done is to import the Type Library for the object.  This makes working with the object much easier, since a Pascal header file is automatically constructed.  To import the type library go to the Project menu in Delphi and select Import Type Library...

From the dialog that appears, the Microsoft Active Data Object should be visible (either the ActiveX Data Object or the ActiveX Data Object RecordSet will work):

Select it and a header file for the object will be built in the Delphi\Imports directory, most likely with a name like: "ADODB_TLB.pas", or "ADOR_TLB.pas".  The header file name should be added to the uses clause of your Delphi Form source code.  Be sure to add the ComObj unit as well:

uses

  Windows, Classes, Forms, ComObj, ADODB_TLB, ...

Then the Active Data Object will need to be created in code.  In this example, an Active Data Object is created to reference an ODBC DataSource called "Craze Sample Data".  This DataSource is using the MSAccess ODBC driver and is pointing to the sample database, Craze.MDB:

var

  frmMain              : TfrmMain;

  {ADO Recordset variables.

   "_RecordSet" is defined in the ADODB_TLB header}

  adoRs1               : _RecordSet;

  adoRs2               : _RecordSet;

implementation

{***********************************************************************}

{ Create the Recordsets                                                 }

{   Two Recordset objects are created and bound to adoRs1 and adoRs2.   }

{***********************************************************************}

procedure CreateRecordSet;

begin

  { Code for creating the recordsets.  Uses the ODBC datasource name }

  { Craze Sample Data to the Access database: Craze.mdb.  Make sure  }

  { that this DSN is properly set up. }

  adoRs1 := CreateOleObject('AdoDB.RecordSet') as _RecordSet;

  adoRs1.Open('Select * from Customer', 'Database=Craze.mdb;Uid=;Pwd=;Dsn=Craze Sample Data', adOpenKeyset, adLockBatchOptimistic, adCmdText);

  adoRs2 := CreateOleObject('AdoDB.RecordSet') as _Recordset;

  adoRs2.Open('Select * from Orders', 'Database=Craze.mdb;Uid=;Pwd=;Dsn=Craze Sample Data', adOpenKeyset, adLockBatchOptimistic, adCmdText);

end;

{***********************************************************************}

{ Set Report Data and Preview the Report                                }

{   Connects the Recordset objects to the Report and Subreport and      }

{   runs the Report to Preview Window.                                  }

{***********************************************************************}

procedure PreviewReport;

begin

  { Open the Report }

  Crpe1.ReportName := 'AdoSample.rpt';

  Crpe1.DiscardData;

  {Get Subreport information}

  Crpe1.Subreports.Retrieve;

  {Set VCL to main Report}

  Crpe1.Subreports[0];

  {Retrieve the Tables}

  Crpe1.Tables.Retrieve;

  {Attach the ADO Recordset to the main Report Table}

  Crpe1.Tables[0].DataPointer := @adoRs1;

  {Set VCL to first Subreport}

  Crpe1.Subreports[1];

  {Retrieve the Subreport Tables}

  Crpe1.Tables.Retrieve;

  {Attach the second ADO Recordset to the Subreport Table}

  Crpe1.Tables[0].DataPointer := @adoRs2;

  {Set VCL back to main Report}

  Crpe1.Subreports[0];

  {Run the Report}

  Crpe1.Execute;

end;


The Active Data Object (ADO) - See also
Related

Active Data Object Header

The Crystal Data Object (CDO)

DataPointer

Bytes

Tag

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Active Data Object Header

See also

Here is an example of the Type Library header file that Delphi generated from the Microsoft Active Data Object.

unit ADODB_TLB;

{ Microsoft ActiveX Data Objects 1.5 Library }

{ Version 2.0 }

{ This file contains pascal declarations imported from a type library.

  This file will be written during each import or refresh of the type

  library editor.  Changes to this file will be discarded during the

  refresh process. }

{ Conversion log:

  Warning: 'Property' is a reserved word. Property changed to Property_

  Warning: 'Object' is a reserved word. Parameter 'Object' in _DynaCollection.Append changed to 'Object_'

  Warning: 'Type' is a reserved word. Property_.Type changed to Type_

  Warning: 'Type' is a reserved word. Parameter 'Type' in _Command.CreateParameter changed to 'Type_'

  Warning: 'Type' is a reserved word. Field.Type changed to Type_

  Warning: 'Type' is a reserved word. _Parameter.Type changed to Type_ }

interface

uses Windows, ActiveX, Classes, Graphics, OleCtrls, StdVCL;

const

  LIBID_ADODB: TGUID = '{00000200-0000-0010-8000-00AA006D2EA4}';

const

{ CursorTypeEnum }

  adOpenUnspecified = -1;

  adOpenForwardOnly = 0;

  adOpenKeyset = 1;

  adOpenDynamic = 2;

  adOpenStatic = 3;

{ CursorOptionEnum }

  adHoldRecords = 256;

  adMovePrevious = 512;

  adAddNew = 16778240;

  adDelete = 16779264;

  adUpdate = 16809984;

  adBookmark = 8192;

  adApproxPosition = 16384;

  adUpdateBatch = 65536;

  adResync = 131072;

{ LockTypeEnum }

  adLockUnspecified = -1;

  adLockReadOnly = 1;

  adLockPessimistic = 2;

  adLockOptimistic = 3;

  adLockBatchOptimistic = 4;

{ ExecuteOptionEnum }

  adOptionUnspecified = -1;

{ ObjectStateEnum }

  adStateClosed = 0;

  adStateOpen = 1;

{ CursorLocationEnum }

  adUseNone = 1;

  adUseServer = 2;

  adUseClient = 3;

  adUseClientBatch = 3;

{ DataTypeEnum }

  adEmpty = 0;

  adTinyInt = 16;

  adSmallInt = 2;

  adInteger = 3;

  adBigInt = 20;

  adUnsignedTinyInt = 17;

  adUnsignedSmallInt = 18;

  adUnsignedInt = 19;

  adUnsignedBigInt = 21;

  adSingle = 4;

  adDouble = 5;

  adCurrency = 6;

  adDecimal = 14;

  adNumeric = 131;

  adBoolean = 11;

  adError = 10;

  adUserDefined = 132;

  adVariant = 12;

  adIDispatch = 9;

  adIUnknown = 13;

  adGUID = 72;

  adDate = 7;

  adDBDate = 133;

  adDBTime = 134;

  adDBTimeStamp = 135;

  adBSTR = 8;

  adChar = 129;

  adVarChar = 200;

  adLongVarChar = 201;

  adWChar = 130;

  adVarWChar = 202;

  adLongVarWChar = 203;

  adBinary = 128;

  adVarBinary = 204;

  adLongVarBinary = 205;

{ FieldAttributeEnum }

  adFldMayDefer = 2;

  adFldUpdatable = 4;

  adFldUnknownUpdatable = 8;

  adFldFixed = 16;

  adFldIsNullable = 32;

  adFldMayBeNull = 64;

  adFldLong = 128;

  adFldRowID = 256;

  adFldRowVersion = 512;

  adFldCacheDeferred = 4096;

{ EditModeEnum }

  adEditNone = 0;

  adEditInProgress = 1;

  adEditAdd = 2;

  adEditDelete = 4;

{ RecordStatusEnum }

  adRecOK = 0;

  adRecNew = 1;

  adRecModified = 2;

  adRecDeleted = 4;

  adRecUnmodified = 8;

  adRecInvalid = 16;

  adRecMultipleChanges = 64;

  adRecPendingChanges = 128;

  adRecCanceled = 256;

  adRecCantRelease = 1024;

  adRecConcurrencyViolation = 2048;

  adRecIntegrityViolation = 4096;

  adRecMaxChangesExceeded = 8192;

  adRecObjectOpen = 16384;

  adRecOutOfMemory = 32768;

  adRecPermissionDenied = 65536;

  adRecSchemaViolation = 131072;

  adRecDBDeleted = 262144;

{ GetRowsOptionEnum }

  adGetRowsRest = -1;

{ PositionEnum }

  adPosUnknown = -1;

  adPosBOF = -2;

  adPosEOF = -3;

{ BookmarkEnum }

  adBookmarkCurrent = 0;

  adBookmarkFirst = 1;

  adBookmarkLast = 2;

{ MarshalOptionsEnum }

  adMarshalAll = 0;

  adMarshalModifiedOnly = 1;

{ AffectEnum }

  adAffectCurrent = 1;

  adAffectGroup = 2;

  adAffectAll = 3;

{ FilterGroupEnum }

  adFilterNone = 0;

  adFilterPendingRecords = 1;

  adFilterAffectedRecords = 2;

  adFilterFetchedRecords = 3;

  adFilterPredicate = 4;

{ SearchDirection }

  adSearchForward = 1;

  adSearchBackward = -1;

{ ConnectPromptEnum }

  adPromptAlways = 1;

  adPromptComplete = 2;

  adPromptCompleteRequired = 3;

  adPromptNever = 4;

{ ConnectModeEnum }

  adModeUnknown = 0;

  adModeRead = 1;

  adModeWrite = 2;

  adModeReadWrite = 3;

  adModeShareDenyRead = 4;

  adModeShareDenyWrite = 8;

  adModeShareExclusive = 12;

  adModeShareDenyNone = 16;

{ IsolationLevelEnum }

  adXactUnspecified = -1;

  adXactChaos = 16;

  adXactReadUncommitted = 256;

  adXactBrowse = 256;

  adXactCursorStability = 4096;

  adXactReadCommitted = 4096;

  adXactRepeatableRead = 65536;

  adXactSerializable = 1048576;

  adXactIsolated = 1048576;

{ XactAttributeEnum }

  adXactCommitRetaining = 131072;

  adXactAbortRetaining = 262144;

{ PropertyAttributesEnum }

  adPropNotSupported = 0;

  adPropRequired = 1;

  adPropOptional = 2;

  adPropRead = 512;

  adPropWrite = 1024;

{ ErrorValueEnum }

  adErrInvalidArgument = 3001;

  adErrNoCurrentRecord = 3021;

  adErrIllegalOperation = 3219;

  adErrInTransaction = 3246;

  adErrFeatureNotAvailable = 3251;

  adErrItemNotFound = 3265;

  adErrObjectInCollection = 3367;

  adErrObjectNotSet = 3420;

  adErrDataConversion = 3421;

  adErrObjectClosed = 3704;

  adErrObjectOpen = 3705;

  adErrProviderNotFound = 3706;

  adErrBoundToCommand = 3707;

  adErrInvalidParamInfo = 3708;

  adErrInvalidConnection = 3709;

  adErrUnsafeOperation = 3716;

{ ParameterAttributesEnum }

  adParamSigned = 16;

  adParamNullable = 64;

  adParamLong = 128;

{ ParameterDirectionEnum }

  adParamUnknown = 0;

  adParamInput = 1;

  adParamOutput = 2;

  adParamInputOutput = 3;

  adParamReturnValue = 4;

{ CommandTypeEnum }

  adCmdUnspecified = -1;

  adCmdUnknown = 8;

  adCmdText = 1;

  adCmdTable = 2;

  adCmdStoredProc = 4;

{ SchemaEnum }

  adSchemaProviderSpecific = -1;

  adSchemaAsserts = 0;

  adSchemaCatalogs = 1;

  adSchemaCharacterSets = 2;

  adSchemaCollations = 3;

  adSchemaColumns = 4;

  adSchemaCheckConstraints = 5;

  adSchemaConstraintColumnUsage = 6;

  adSchemaConstraintTableUsage = 7;

  adSchemaKeyColumnUsage = 8;

  adSchemaReferentialContraints = 9;

  adSchemaTableConstraints = 10;

  adSchemaColumnsDomainUsage = 11;

  adSchemaIndexes = 12;

  adSchemaColumnPrivileges = 13;

  adSchemaTablePrivileges = 14;

  adSchemaUsagePrivileges = 15;

  adSchemaProcedures = 16;

  adSchemaSchemata = 17;

  adSchemaSQLLanguages = 18;

  adSchemaStatistics = 19;

  adSchemaTables = 20;

  adSchemaTranslations = 21;

  adSchemaProviderTypes = 22;

  adSchemaViews = 23;

  adSchemaViewColumnUsage = 24;

  adSchemaViewTableUsage = 25;

  adSchemaProcedureParameters = 26;

  adSchemaForeignKeys = 27;

  adSchemaPrimaryKeys = 28;

  adSchemaProcedureColumns = 29;

const

{ Component class GUIDs }

  Class_Connection: TGUID = '{00000514-0000-0010-8000-00AA006D2EA4}';

  Class_Command: TGUID = '{00000507-0000-0010-8000-00AA006D2EA4}';

  Class_Recordset: TGUID = '{00000535-0000-0010-8000-00AA006D2EA4}';

  Class_Parameter: TGUID = '{0000050B-0000-0010-8000-00AA006D2EA4}';

type

{ Forward declarations: Interfaces }

  _Collection = interface;

  _CollectionDisp = dispinterface;

  _DynaCollection = interface;

  _DynaCollectionDisp = dispinterface;

  _ADO = interface;

  _ADODisp = dispinterface;

  Properties = interface;

  PropertiesDisp = dispinterface;

  Property_ = interface;

  Property_Disp = dispinterface;

  Error = interface;

  ErrorDisp = dispinterface;

  Errors = interface;

  ErrorsDisp = dispinterface;

  _Command = interface;

  _CommandDisp = dispinterface;

  _Connection = interface;

  _ConnectionDisp = dispinterface;

  _Recordset = interface;

  _RecordsetDisp = dispinterface;

  Fields = interface;

  FieldsDisp = dispinterface;

  Field = interface;

  FieldDisp = dispinterface;

  _Parameter = interface;

  _ParameterDisp = dispinterface;

  Parameters = interface;

  ParametersDisp = dispinterface;

  ADOConnectionConstruction = interface;

  ADORecordsetConstruction = interface;

{ Forward declarations: CoClasses }

  Connection = _Connection;

  Command = _Command;

  Recordset = _Recordset;

  Parameter = _Parameter;

{ Forward declarations: Enums }

  CursorTypeEnum = TOleEnum;

  CursorOptionEnum = TOleEnum;

  LockTypeEnum = TOleEnum;

  ExecuteOptionEnum = TOleEnum;

  ObjectStateEnum = TOleEnum;

  CursorLocationEnum = TOleEnum;

  DataTypeEnum = TOleEnum;

  FieldAttributeEnum = TOleEnum;

  EditModeEnum = TOleEnum;

  RecordStatusEnum = TOleEnum;

  GetRowsOptionEnum = TOleEnum;

  PositionEnum = TOleEnum;

  BookmarkEnum = TOleEnum;

  MarshalOptionsEnum = TOleEnum;

  AffectEnum = TOleEnum;

  FilterGroupEnum = TOleEnum;

  SearchDirection = TOleEnum;

  ConnectPromptEnum = TOleEnum;

  ConnectModeEnum = TOleEnum;

  IsolationLevelEnum = TOleEnum;

  XactAttributeEnum = TOleEnum;

  PropertyAttributesEnum = TOleEnum;

  ErrorValueEnum = TOleEnum;

  ParameterAttributesEnum = TOleEnum;

  ParameterDirectionEnum = TOleEnum;

  CommandTypeEnum = TOleEnum;

  SchemaEnum = TOleEnum;

  SearchDirectionEnum = SearchDirection;

  _Collection = interface(IDispatch)

    ['{00000512-0000-0010-8000-00AA006D2EA4}']

    function Get_Count: Integer; safecall;

    function _NewEnum: IUnknown; safecall;

    procedure Refresh; safecall;

    property Count: Integer read Get_Count;

  end;

{ DispInterface declaration for Dual Interface _Collection }

  _CollectionDisp = dispinterface

    ['{00000512-0000-0010-8000-00AA006D2EA4}']

    property Count: Integer readonly;

    procedure Refresh;

  end;

  _DynaCollection = interface(_Collection)

    ['{00000513-0000-0010-8000-00AA006D2EA4}']

    procedure Append(Object_: IDispatch); safecall;

    procedure Delete(Index: OleVariant); safecall;

  end;

{ DispInterface declaration for Dual Interface _DynaCollection }

  _DynaCollectionDisp = dispinterface

    ['{00000513-0000-0010-8000-00AA006D2EA4}']

    procedure Append(Object_: IDispatch);

    procedure Delete(Index: OleVariant);

  end;

  _ADO = interface(IDispatch)

    ['{00000534-0000-0010-8000-00AA006D2EA4}']

    function Get_Properties: Properties; safecall;

    property Properties: Properties read Get_Properties;

  end;

{ DispInterface declaration for Dual Interface _ADO }

  _ADODisp = dispinterface

    ['{00000534-0000-0010-8000-00AA006D2EA4}']

    property Properties: Properties readonly dispid 500;

  end;

{ Collection of Property objects }

  Properties = interface(_Collection)

    ['{00000504-0000-0010-8000-00AA006D2EA4}']

    function Get_Item(Index: OleVariant): Property_; safecall;

    property Item[Index: OleVariant]: Property_ read Get_Item; default;

  end;

{ DispInterface declaration for Dual Interface Properties }

  PropertiesDisp = dispinterface

    ['{00000504-0000-0010-8000-00AA006D2EA4}']

    property Item[Index: OleVariant]: Property_ readonly dispid 0; default;

  end;

{ Built in or user defined property }

  Property_ = interface(IDispatch)

    ['{00000503-0000-0010-8000-00AA006D2EA4}']

    function Get_Value: OleVariant; safecall;

    procedure Set_Value(Value: OleVariant); safecall;

    function Get_Name: WideString; safecall;

    function Get_Type_: DataTypeEnum; safecall;

    function Get_Attributes: Integer; safecall;

    procedure Set_Attributes(Value: Integer); safecall;

    property Value: OleVariant read Get_Value write Set_Value;

    property Name: WideString read Get_Name;

    property Type_: DataTypeEnum read Get_Type_;

    property Attributes: Integer read Get_Attributes write Set_Attributes;

  end;

{ DispInterface declaration for Dual Interface Property_ }

  Property_Disp = dispinterface

    ['{00000503-0000-0010-8000-00AA006D2EA4}']

    property Value: OleVariant dispid 0;

    property Name: WideString readonly;

    property Type_: DataTypeEnum readonly;

    property Attributes: Integer;

  end;

{ Object containing details of errors for a single operation involving ADO }

  Error = interface(IDispatch)

    ['{00000500-0000-0010-8000-00AA006D2EA4}']

    function Get_Number: Integer; safecall;

    function Get_Source: WideString; safecall;

    function Get_Description: WideString; safecall;

    function Get_HelpFile: WideString; safecall;

    function Get_HelpContext: Integer; safecall;

    function Get_SQLState: WideString; safecall;

    function Get_NativeError: Integer; safecall;

    property Number: Integer read Get_Number;

    property Source: WideString read Get_Source;

    property Description: WideString read Get_Description;

    property HelpFile: WideString read Get_HelpFile;

    property HelpContext: Integer read Get_HelpContext;

    property SQLState: WideString read Get_SQLState;

    property NativeError: Integer read Get_NativeError;

  end;

{ DispInterface declaration for Dual Interface Error }

  ErrorDisp = dispinterface

    ['{00000500-0000-0010-8000-00AA006D2EA4}']

    property Number: Integer readonly;

    property Source: WideString readonly;

    property Description: WideString readonly dispid 0;

    property HelpFile: WideString readonly;

    property HelpContext: Integer readonly;

    property SQLState: WideString readonly;

    property NativeError: Integer readonly;

  end;

{ Collection of Error objects }

  Errors = interface(_Collection)

    ['{00000501-0000-0010-8000-00AA006D2EA4}']

    function Get_Item(Index: OleVariant): Error; safecall;

    procedure Clear; safecall;

    property Item[Index: OleVariant]: Error read Get_Item; default;

  end;

{ DispInterface declaration for Dual Interface Errors }

  ErrorsDisp = dispinterface

    ['{00000501-0000-0010-8000-00AA006D2EA4}']

    property Item[Index: OleVariant]: Error readonly dispid 0; default;

    procedure Clear;

  end;

  _Command = interface(_ADO)

    ['{00000508-0000-0010-8000-00AA006D2EA4}']

    function Get_ActiveConnection: _Connection; safecall;

    procedure Set_ActiveConnection(var Value: _Connection); safecall;

    procedure _Set_ActiveConnection(const Value: _Connection); safecall;

    function Get_CommandText: WideString; safecall;

    procedure Set_CommandText(const Value: WideString); safecall;

    function Get_CommandTimeout: Integer; safecall;

    procedure Set_CommandTimeout(Value: Integer); safecall;

    function Get_Prepared: WordBool; safecall;

    procedure Set_Prepared(Value: WordBool); safecall;

    function Execute(out RecordsAffected: OleVariant; var Parameters: OleVariant; Options: Integer): _Recordset; safecall;

    function CreateParameter(const Name: WideString; Type_: DataTypeEnum; Direction: ParameterDirectionEnum; Size: Integer; Value: OleVariant): _Parameter; safecall;

    function Get_Parameters: Parameters; safecall;

    procedure Set_CommandType(Value: CommandTypeEnum); safecall;

    function Get_CommandType: CommandTypeEnum; safecall;

    function Get_Name: WideString; safecall;

    procedure Set_Name(const Value: WideString); safecall;

    property ActiveConnection: _Connection read Get_ActiveConnection write Set_ActiveConnection;

    property CommandText: WideString read Get_CommandText write Set_CommandText;

    property CommandTimeout: Integer read Get_CommandTimeout write Set_CommandTimeout;

    property Prepared: WordBool read Get_Prepared write Set_Prepared;

    property Parameters: Parameters read Get_Parameters;

    property CommandType: CommandTypeEnum read Get_CommandType write Set_CommandType;

    property Name: WideString read Get_Name write Set_Name;

  end;

{ DispInterface declaration for Dual Interface _Command }

  _CommandDisp = dispinterface

    ['{00000508-0000-0010-8000-00AA006D2EA4}']

    property ActiveConnection: _Connection;

    property CommandText: WideString;

    property CommandTimeout: Integer;

    property Prepared: WordBool;

    function Execute(out RecordsAffected: OleVariant; var Parameters: OleVariant; Options: Integer): _Recordset;

    function CreateParameter(const Name: WideString; Type_: DataTypeEnum; Direction: ParameterDirectionEnum; Size: Integer; Value: OleVariant): _Parameter;

    property Parameters: Parameters readonly dispid 0;

    property CommandType: CommandTypeEnum;

    property Name: WideString;

  end;

{ Representation of an open connection to an OLE DB data source }

  _Connection = interface(_ADO)

    ['{00000515-0000-0010-8000-00AA006D2EA4}']

    function Get_ConnectionString: WideString; safecall;

    procedure Set_ConnectionString(const Value: WideString); safecall;

    function Get_CommandTimeout: Integer; safecall;

    procedure Set_CommandTimeout(Value: Integer); safecall;

    function Get_ConnectionTimeout: Integer; safecall;

    procedure Set_ConnectionTimeout(Value: Integer); safecall;

    function Get_Version: WideString; safecall;

    procedure Close; safecall;

    function Execute(const CommandText: WideString; out RecordsAffected: OleVariant; Options: Integer): _Recordset; safecall;

    function BeginTrans: Integer; safecall;

    procedure CommitTrans; safecall;

    procedure RollbackTrans; safecall;

    procedure Open(const ConnectionString, UserID, Password: WideString; Options: Integer); safecall;

    function Get_Errors: Errors; safecall;

    function Get_DefaultDatabase: WideString; safecall;

    procedure Set_DefaultDatabase(const Value: WideString); safecall;

    function Get_IsolationLevel: IsolationLevelEnum; safecall;

    procedure Set_IsolationLevel(Value: IsolationLevelEnum); safecall;

    function Get_Attributes: Integer; safecall;

    procedure Set_Attributes(Value: Integer); safecall;

    function Get_CursorLocation: CursorLocationEnum; safecall;

    procedure Set_CursorLocation(Value: CursorLocationEnum); safecall;

    function Get_Mode: ConnectModeEnum; safecall;

    procedure Set_Mode(Value: ConnectModeEnum); safecall;

    function Get_Provider: WideString; safecall;

    procedure Set_Provider(const Value: WideString); safecall;

    function Get_State: Integer; safecall;

    function OpenSchema(Schema: SchemaEnum; Restrictions, SchemaID: OleVariant): _Recordset; safecall;

    property ConnectionString: WideString read Get_ConnectionString write Set_ConnectionString;

    property CommandTimeout: Integer read Get_CommandTimeout write Set_CommandTimeout;

    property ConnectionTimeout: Integer read Get_ConnectionTimeout write Set_ConnectionTimeout;

    property Version: WideString read Get_Version;

    property Errors: Errors read Get_Errors;

    property DefaultDatabase: WideString read Get_DefaultDatabase write Set_DefaultDatabase;

    property IsolationLevel: IsolationLevelEnum read Get_IsolationLevel write Set_IsolationLevel;

    property Attributes: Integer read Get_Attributes write Set_Attributes;

    property CursorLocation: CursorLocationEnum read Get_CursorLocation write Set_CursorLocation;

    property Mode: ConnectModeEnum read Get_Mode write Set_Mode;

    property Provider: WideString read Get_Provider write Set_Provider;

    property State: Integer read Get_State;

  end;

{ DispInterface declaration for Dual Interface _Connection }

  _ConnectionDisp = dispinterface

    ['{00000515-0000-0010-8000-00AA006D2EA4}']

    property Properties: Properties readonly dispid 500;

    property ConnectionString: WideString dispid 0;

    property CommandTimeout: Integer dispid 2;

    property ConnectionTimeout: Integer dispid 3;

    property Version: WideString readonly dispid 4;

    procedure Close; dispid 5;

    function Execute(const CommandText: WideString; out RecordsAffected: OleVariant; Options: Integer): _Recordset; dispid 6;

    function BeginTrans: Integer; dispid 7;

    procedure CommitTrans; dispid 8;

    procedure RollbackTrans; dispid 9;

    procedure Open(const ConnectionString, UserID, Password: WideString; Options: Integer); dispid 10;

    property Errors: Errors readonly dispid 11;

    property DefaultDatabase: WideString dispid 12;

    property IsolationLevel: IsolationLevelEnum dispid 13;

    property Attributes: Integer dispid 14;

    property CursorLocation: CursorLocationEnum dispid 15;

    property Mode: ConnectModeEnum dispid 16;

    property Provider: WideString dispid 17;

    property State: Integer readonly dispid 18;

    function OpenSchema(Schema: SchemaEnum; Restrictions, SchemaID: OleVariant): _Recordset; dispid 19;

  end;

{ Data cursor representing a record in a base table or command results }

  _Recordset = interface(_ADO)

    ['{0000050E-0000-0010-8000-00AA006D2EA4}']

    function Get_AbsolutePosition: PositionEnum; safecall;

    procedure Set_AbsolutePosition(Value: PositionEnum); safecall;

    procedure Set_ActiveConnection(var Value: IDispatch); safecall;

    procedure _Set_ActiveConnection(Value: IDispatch); safecall;

    function Get_ActiveConnection: IDispatch; safecall;

    function Get_BOF: WordBool; safecall;

    function Get_Bookmark: OleVariant; safecall;

    procedure Set_Bookmark(Value: OleVariant); safecall;

    function Get_CacheSize: Integer; safecall;

    procedure Set_CacheSize(Value: Integer); safecall;

    function Get_CursorType: CursorTypeEnum; safecall;

    procedure Set_CursorType(Value: CursorTypeEnum); safecall;

    function Get_EOF: WordBool; safecall;

    function Get_Fields: Fields; safecall;

    function Get_LockType: LockTypeEnum; safecall;

    procedure Set_LockType(Value: LockTypeEnum); safecall;

    function Get_MaxRecords: Integer; safecall;

    procedure Set_MaxRecords(Value: Integer); safecall;

    function Get_RecordCount: Integer; safecall;

    procedure Set_Source(var Value: IDispatch); safecall;

    procedure _Set_Source(Value: IDispatch); safecall;

    function Get_Source: IDispatch; safecall;

    procedure AddNew(FieldList, Values: OleVariant); safecall;

    procedure CancelUpdate; safecall;

    procedure Close; safecall;

    procedure Delete(AffectRecords: AffectEnum); safecall;

    function GetRows(Rows: Integer; Start, Fields: OleVariant): OleVariant; safecall;

    procedure Move(NumRecords: Integer; Start: OleVariant); safecall;

    procedure MoveNext; safecall;

    procedure MovePrevious; safecall;

    procedure MoveFirst; safecall;

    procedure MoveLast; safecall;

    procedure Open(Source, ActiveConnection: OleVariant; CursorType: CursorTypeEnum; LockType: LockTypeEnum; Options: Integer); safecall;

    procedure Requery(Options: Integer); safecall;

    procedure Resync(AffectRecords: AffectEnum); safecall;

    procedure Update(Fields, Values: OleVariant); safecall;

    function Get_AbsolutePage: PositionEnum; safecall;

    procedure Set_AbsolutePage(Value: PositionEnum); safecall;

    function Get_EditMode: EditModeEnum; safecall;

    function Get_Filter: OleVariant; safecall;

    procedure Set_Filter(Value: OleVariant); safecall;

    function Get_PageCount: Integer; safecall;

    function Get_PageSize: Integer; safecall;

    procedure Set_PageSize(Value: Integer); safecall;

    function Get_Sort: WideString; safecall;

    procedure Set_Sort(const Value: WideString); safecall;

    function Get_Status: Integer; safecall;

    function Get_State: Integer; safecall;

    function Clone: _Recordset; safecall;

    procedure UpdateBatch(AffectRecords: AffectEnum); safecall;

    procedure CancelBatch(AffectRecords: AffectEnum); safecall;

    function Get_CursorLocation: CursorLocationEnum; safecall;

    procedure Set_CursorLocation(Value: CursorLocationEnum); safecall;

    function NextRecordset(out RecordsAffected: OleVariant): _Recordset; safecall;

    function Supports(CursorOptions: CursorOptionEnum): WordBool; safecall;

    function Get_Collect(Index: OleVariant): OleVariant; safecall;

    procedure Set_Collect(Index: OleVariant; Value: OleVariant); safecall;

    function Get_MarshalOptions: MarshalOptionsEnum; safecall;

    procedure Set_MarshalOptions(Value: MarshalOptionsEnum); safecall;

    procedure Find(const Criteria: WideString; SkipRecords: Integer; SearchDirection: SearchDirectionEnum; Start: OleVariant); safecall;

    property AbsolutePosition: PositionEnum read Get_AbsolutePosition write Set_AbsolutePosition;

    property ActiveConnection: IDispatch read Get_ActiveConnection write Set_ActiveConnection;

    property BOF: WordBool read Get_BOF;

    property Bookmark: OleVariant read Get_Bookmark write Set_Bookmark;

    property CacheSize: Integer read Get_CacheSize write Set_CacheSize;

    property CursorType: CursorTypeEnum read Get_CursorType write Set_CursorType;

    property EOF: WordBool read Get_EOF;

    property Fields: Fields read Get_Fields;

    property LockType: LockTypeEnum read Get_LockType write Set_LockType;

    property MaxRecords: Integer read Get_MaxRecords write Set_MaxRecords;

    property RecordCount: Integer read Get_RecordCount;

    property Source: IDispatch read Get_Source write Set_Source;

    property AbsolutePage: PositionEnum read Get_AbsolutePage write Set_AbsolutePage;

    property EditMode: EditModeEnum read Get_EditMode;

    property Filter: OleVariant read Get_Filter write Set_Filter;

    property PageCount: Integer read Get_PageCount;

    property PageSize: Integer read Get_PageSize write Set_PageSize;

    property Sort: WideString read Get_Sort write Set_Sort;

    property Status: Integer read Get_Status;

    property State: Integer read Get_State;

    property CursorLocation: CursorLocationEnum read Get_CursorLocation write Set_CursorLocation;

    property Collect[Index: OleVariant]: OleVariant read Get_Collect write Set_Collect;

    property MarshalOptions: MarshalOptionsEnum read Get_MarshalOptions write Set_MarshalOptions;

  end;

{ DispInterface declaration for Dual Interface _Recordset }

  _RecordsetDisp = dispinterface

    ['{0000050E-0000-0010-8000-00AA006D2EA4}']

    property AbsolutePosition: PositionEnum dispid 1000;

    property ActiveConnection: IDispatch dispid 1001;

    property BOF: WordBool readonly dispid 1002;

    property Bookmark: OleVariant dispid 1003;

    property CacheSize: Integer dispid 1004;

    property CursorType: CursorTypeEnum dispid 1005;

    property EOF: WordBool readonly dispid 1006;

    property Fields: Fields readonly dispid 0;

    property LockType: LockTypeEnum dispid 1008;

    property MaxRecords: Integer dispid 1009;

    property RecordCount: Integer readonly dispid 1010;

    property Source: IDispatch dispid 1011;

    procedure AddNew(FieldList, Values: OleVariant); dispid 1012;

    procedure CancelUpdate; dispid 1013;

    procedure Close; dispid 1014;

    procedure Delete(AffectRecords: AffectEnum); dispid 1015;

    function GetRows(Rows: Integer; Start, Fields: OleVariant): OleVariant; dispid 1016;

    procedure Move(NumRecords: Integer; Start: OleVariant); dispid 1017;

    procedure MoveNext; dispid 1018;

    procedure MovePrevious; dispid 1019;

    procedure MoveFirst; dispid 1020;

    procedure MoveLast; dispid 1021;

    procedure Open(Source, ActiveConnection: OleVariant; CursorType: CursorTypeEnum; LockType: LockTypeEnum; Options: Integer); dispid 1022;

    procedure Requery(Options: Integer); dispid 1023;

    procedure Resync(AffectRecords: AffectEnum); dispid 1024;

    procedure Update(Fields, Values: OleVariant); dispid 1025;

    property AbsolutePage: PositionEnum dispid 1047;

    property EditMode: EditModeEnum readonly dispid 1026;

    property Filter: OleVariant dispid 1030;

    property PageCount: Integer readonly dispid 1050;

    property PageSize: Integer dispid 1048;

    property Sort: WideString dispid 1031;

    property Status: Integer readonly dispid 1029;

    property State: Integer readonly dispid 1054;

    function Clone: _Recordset; dispid 1034;

    procedure UpdateBatch(AffectRecords: AffectEnum); dispid 1035;

    procedure CancelBatch(AffectRecords: AffectEnum); dispid 1049;

    property CursorLocation: CursorLocationEnum dispid 1051;

    function NextRecordset(out RecordsAffected: OleVariant): _Recordset; dispid 1052;

    function Supports(CursorOptions: CursorOptionEnum): WordBool; dispid 1036;

    property Collect[Index: OleVariant]: OleVariant dispid -8;

    property MarshalOptions: MarshalOptionsEnum dispid 1053;

    procedure Find(const Criteria: WideString; SkipRecords: Integer; SearchDirection: SearchDirectionEnum; Start: OleVariant); dispid 1058;

  end;

{ Collection of Field objects }

  Fields = interface(_Collection)

    ['{00000506-0000-0010-8000-00AA006D2EA4}']

    function Get_Item(Index: OleVariant): Field; safecall;

    property Item[Index: OleVariant]: Field read Get_Item; default;

  end;

{ DispInterface declaration for Dual Interface Fields }

  FieldsDisp = dispinterface

    ['{00000506-0000-0010-8000-00AA006D2EA4}']

    property Item[Index: OleVariant]: Field readonly dispid 0; default;

  end;

{ Representation of a 'column' of data }

  Field = interface(_ADO)

    ['{00000505-0000-0010-8000-00AA006D2EA4}']

    function Get_ActualSize: Integer; safecall;

    function Get_Attributes: Integer; safecall;

    function Get_DefinedSize: Integer; safecall;

    function Get_Name: WideString; safecall;

    function Get_Type_: DataTypeEnum; safecall;

    function Get_Value: OleVariant; safecall;

    procedure Set_Value(Value: OleVariant); safecall;

    function Get_Precision: Byte; safecall;

    function Get_NumericScale: Byte; safecall;

    procedure AppendChunk(Data: OleVariant); safecall;

    function GetChunk(Length: Integer): OleVariant; safecall;

    function Get_OriginalValue: OleVariant; safecall;

    function Get_UnderlyingValue: OleVariant; safecall;

    property ActualSize: Integer read Get_ActualSize;

    property Attributes: Integer read Get_Attributes;

    property DefinedSize: Integer read Get_DefinedSize;

    property Name: WideString read Get_Name;

    property Type_: DataTypeEnum read Get_Type_;

    property Value: OleVariant read Get_Value write Set_Value;

    property Precision: Byte read Get_Precision;

    property NumericScale: Byte read Get_NumericScale;

    property OriginalValue: OleVariant read Get_OriginalValue;

    property UnderlyingValue: OleVariant read Get_UnderlyingValue;

  end;

{ DispInterface declaration for Dual Interface Field }

  FieldDisp = dispinterface

    ['{00000505-0000-0010-8000-00AA006D2EA4}']

    property ActualSize: Integer readonly dispid 1109;

    property Attributes: Integer readonly dispid 1036;

    property DefinedSize: Integer readonly dispid 1103;

    property Name: WideString readonly dispid 1100;

    property Type_: DataTypeEnum readonly dispid 1102;

    property Value: OleVariant dispid 0;

    property Precision: Byte readonly;

    property NumericScale: Byte readonly;

    procedure AppendChunk(Data: OleVariant); dispid 1107;

    function GetChunk(Length: Integer): OleVariant; dispid 1108;

    property OriginalValue: OleVariant readonly dispid 1104;

    property UnderlyingValue: OleVariant readonly dispid 1105;

  end;

{ Argument associated with a Command Object based on a parameterized query/SP }

  _Parameter = interface(_ADO)

    ['{0000050C-0000-0010-8000-00AA006D2EA4}']

    function Get_Name: WideString; safecall;

    procedure Set_Name(const Value: WideString); safecall;

    function Get_Value: OleVariant; safecall;

    procedure Set_Value(Value: OleVariant); safecall;

    function Get_Type_: DataTypeEnum; safecall;

    procedure Set_Type_(Value: DataTypeEnum); safecall;

    procedure Set_Direction(Value: ParameterDirectionEnum); safecall;

    function Get_Direction: ParameterDirectionEnum; safecall;

    procedure Set_Precision(Value: Byte); safecall;

    function Get_Precision: Byte; safecall;

    procedure Set_NumericScale(Value: Byte); safecall;

    function Get_NumericScale: Byte; safecall;

    procedure Set_Size(Value: Integer); safecall;

    function Get_Size: Integer; safecall;

    procedure AppendChunk(Val: OleVariant); safecall;

    function Get_Attributes: Integer; safecall;

    procedure Set_Attributes(Value: Integer); safecall;

    property Name: WideString read Get_Name write Set_Name;

    property Value: OleVariant read Get_Value write Set_Value;

    property Type_: DataTypeEnum read Get_Type_ write Set_Type_;

    property Direction: ParameterDirectionEnum read Get_Direction write Set_Direction;

    property Precision: Byte read Get_Precision write Set_Precision;

    property NumericScale: Byte read Get_NumericScale write Set_NumericScale;

    property Size: Integer read Get_Size write Set_Size;

    property Attributes: Integer read Get_Attributes write Set_Attributes;

  end;

{ DispInterface declaration for Dual Interface _Parameter }

  _ParameterDisp = dispinterface

    ['{0000050C-0000-0010-8000-00AA006D2EA4}']

    property Name: WideString;

    property Value: OleVariant dispid 0;

    property Type_: DataTypeEnum;

    property Direction: ParameterDirectionEnum;

    property Precision: Byte;

    property NumericScale: Byte;

    property Size: Integer;

    procedure AppendChunk(Val: OleVariant);

    property Attributes: Integer;

  end;

{ Collection of Parameter objects }

  Parameters = interface(_DynaCollection)

    ['{0000050D-0000-0010-8000-00AA006D2EA4}']

    function Get_Item(Index: OleVariant): _Parameter; safecall;

    property Item[Index: OleVariant]: _Parameter read Get_Item; default;

  end;

{ DispInterface declaration for Dual Interface Parameters }

  ParametersDisp = dispinterface

    ['{0000050D-0000-0010-8000-00AA006D2EA4}']

    property Item[Index: OleVariant]: _Parameter readonly dispid 0; default;

  end;

  ADOConnectionConstruction = interface(IUnknown)

    ['{00000516-0000-0010-8000-00AA006D2EA4}']

    function Get_DSO: IUnknown; safecall;

    function Get_Session: IUnknown; safecall;

    property DSO: IUnknown read Get_DSO;

    property Session: IUnknown read Get_Session;

  end;

  ADORecordsetConstruction = interface(IDispatch)

    ['{00000283-0000-0010-8000-00AA006D2EA4}']

    function Get_Rowset: IUnknown; safecall;

    procedure Set_Rowset(Value: IUnknown); safecall;

    function Get_Chapter: Integer; safecall;

    procedure Set_Chapter(Value: Integer); safecall;

    function Get_RowPosition: IUnknown; safecall;

    procedure Set_RowPosition(Value: IUnknown); safecall;

    property Rowset: IUnknown read Get_Rowset write Set_Rowset;

    property Chapter: Integer read Get_Chapter write Set_Chapter;

    property RowPosition: IUnknown read Get_RowPosition write Set_RowPosition;

  end;

  CoConnection = class

    class function Create: _Connection;

    class function CreateRemote(const MachineName: string): _Connection;

  end;

  CoCommand = class

    class function Create: _Command;

    class function CreateRemote(const MachineName: string): _Command;

  end;

  CoRecordset = class

    class function Create: _Recordset;

    class function CreateRemote(const MachineName: string): _Recordset;

  end;

  CoParameter = class

    class function Create: _Parameter;

    class function CreateRemote(const MachineName: string): _Parameter;

  end;

implementation

uses ComObj;

class function CoConnection.Create: _Connection;

begin

  Result := CreateComObject(Class_Connection) as _Connection;

end;

class function CoConnection.CreateRemote(const MachineName: string): _Connection;

begin

  Result := CreateRemoteComObject(MachineName, Class_Connection) as _Connection;

end;

class function CoCommand.Create: _Command;

begin

  Result := CreateComObject(Class_Command) as _Command;

end;

class function CoCommand.CreateRemote(const MachineName: string): _Command;

begin

  Result := CreateRemoteComObject(MachineName, Class_Command) as _Command;

end;

class function CoRecordset.Create: _Recordset;

begin

  Result := CreateComObject(Class_Recordset) as _Recordset;

end;

class function CoRecordset.CreateRemote(const MachineName: string): _Recordset;

begin

  Result := CreateRemoteComObject(MachineName, Class_Recordset) as _Recordset;

end;

class function CoParameter.Create: _Parameter;

begin

  Result := CreateComObject(Class_Parameter) as _Parameter;

end;

class function CoParameter.CreateRemote(const MachineName: string): _Parameter;

begin

  Result := CreateRemoteComObject(MachineName, Class_Parameter) as _Parameter;

end;

end.


Active Data Object Header - See also
Related

The Active Data Object (ADO)

The Crystal Data Object (CDO)

Crystal Data Object Header

DataPointer

Bytes

Tag

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Crystal Data Object Header

See also

Here is an example of the Type Library header file that Delphi generated from the Crystal Data Object.

unit CrystalDataObject_TLB;

{ Crystal Data Object }

{ Version 1.0 }

{ This file contains pascal declarations imported from a type library.

  This file will be written during each import or refresh of the type

  library editor.  Changes to this file will be discarded during the

  refresh process. }

interface

uses Windows, ActiveX, Classes, Graphics, OleCtrls, StdVCL;

const

  LIBID_CrystalDataObject: TGUID = '{7C5A4C06-A559-11D0-881A-00AA00BA30B7}';

const

{ Component class GUIDs }

  Class_CrystalComObject: TGUID = '{7C5A4C14-A559-11D0-881A-00AA00BA30B7}';

type

{ Forward declarations: Interfaces }

  ICrystalComObject = dispinterface;

{ Forward declarations: CoClasses }

  CrystalComObject = ICrystalComObject;

  ICrystalComObject = dispinterface

    ['{7C5A4C13-A559-11D0-881A-00AA00BA30B7}']

    property RowCount: Integer dispid 1;

    procedure AddRows(RowData: OleVariant); dispid 2;

    procedure Reset; dispid 3;

    function DeleteField(const FieldName: WideString): WordBool; dispid 4;

    function getEOF: WordBool; dispid 5;

    function MoveNext: WordBool; dispid 6;

    function MoveFirst: WordBool; dispid 7;

    function GetColCount: Smallint; dispid 8;

    function MoveTo(recordNum: Integer): WordBool; dispid 9;

    function AddField(const FieldName: WideString; FieldType: OleVariant): WordBool; dispid 10;

    function GetFieldData(column: Smallint): OleVariant; dispid 11;

    function GetFieldName(column: Smallint): WideString; dispid 12;

    function GetFieldType(Field: OleVariant): Smallint; dispid 13;

  end;

  CoCrystalComObject = class

    class function Create: ICrystalComObject;

    class function CreateRemote(const MachineName: string): ICrystalComObject;

  end;

implementation

uses ComObj;

class function CoCrystalComObject.Create: ICrystalComObject;

begin

  Result := CreateComObject(Class_CrystalComObject) as ICrystalComObject;

end;

class function CoCrystalComObject.CreateRemote(const MachineName: string): ICrystalComObject;

begin

  Result := CreateRemoteComObject(MachineName, Class_CrystalComObject) as ICrystalComObject;

end;

end.


Crystal Data Object Header - See also
Related

The Crystal Data Object (CDO)

The Active Data Object (ADO)

Active Data Object Header

DataPointer

Bytes

Tag

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CRDataSource
CDO vs. the Crystal Data Source Type Library

Seagate Crystal Reports also supports the Crystal Data Source Type Library for implementing in a Visual Basic class definition. Crystal Data Source objects can also be passed to the Active Data Driver as ActiveX data sources. However, the Crystal Data Source Type Library exposes a complete COM interface that must be implemented in your class. CDO, on the other hand, provides a fast and simple method for producing an internal customized ActiveX data source.

If you need to implement a complete data source in your application that allows runtime movement through records and fields, or if you intend to implement your data source as a separate ActiveX component, consider using the Crystal Data Source Type Library. However, if you need to create a quick and simple means of storing a large amount of data in a convenient package for reporting on, and the data will remain inside the same application as the reporting functionality, then use Crystal Data Objects.

unit CRDataSourceLib_TLB;

{ CRDataSource 1.0 Type Library }

{ Version 1.0 }

{ This file contains pascal declarations imported from a type library.

  This file will be written during each import or refresh of the type

  library editor.  Changes to this file will be discarded during the

  refresh process. }

interface

uses Windows, ActiveX, Classes, Graphics, OleCtrls, StdVCL;

const

  LIBID_CRDataSourceLib: TGUID = '{F4ED51C3-E0D5-11D1-92B3-00A0C92765B4}';

const

{ Component class GUIDs }

  Class_CRDataSource: TGUID = '{F4ED51D1-E0D5-11D1-92B3-00A0C92765B4}';

type

{ Forward declarations: Interfaces }

  ICRDataSource = interface;

{ Forward declarations: CoClasses }

  CRDataSource = ICRDataSource;

{ ICRDataSource Interface }

  ICRDataSource = interface(IUnknown)

    ['{F4ED51D0-E0D5-11D1-92B3-00A0C92765B4}']

    function Get_FieldCount: Smallint; safecall;

    function Get_RecordCount: Integer; safecall;

    function Get_FieldName(FieldIndex: Smallint): WideString; safecall;

    function Get_FieldType(FieldIndex: Smallint): Smallint; safecall;

    function Get_FieldValue(FieldIndex: Smallint): OleVariant; safecall;

    procedure MoveFirst; safecall;

    procedure MoveNext; safecall;

    function Get_Bookmark: OleVariant; safecall;

    procedure Set_Bookmark(Value: OleVariant); safecall;

    function Get_EOF: WordBool; safecall;

    property FieldCount: Smallint read Get_FieldCount;

    property RecordCount: Integer read Get_RecordCount;

    property FieldName[FieldIndex: Smallint]: WideString read Get_FieldName;

    property FieldType[FieldIndex: Smallint]: Smallint read Get_FieldType;

    property FieldValue[FieldIndex: Smallint]: OleVariant read Get_FieldValue;

    property Bookmark: OleVariant read Get_Bookmark write Set_Bookmark;

    property EOF: WordBool read Get_EOF;

  end;

{ CRDataSource Class }

  CoCRDataSource = class

    class function Create: ICRDataSource;

    class function CreateRemote(const MachineName: string): ICRDataSource;

  end;

implementation

uses ComObj;

class function CoCRDataSource.Create: ICRDataSource;

begin

  Result := CreateComObject(Class_CRDataSource) as ICRDataSource;

end;

class function CoCRDataSource.CreateRemote(const MachineName: string): ICRDataSource;

begin

  Result := CreateRemoteComObject(MachineName, Class_CRDataSource) as ICRDataSource;

end;

end.


SubName property

See also	Example

Applies to

Tables

Declaration

property SubName: string;

Description

The SubName property is the name of the current Table for databases such as Microsoft Access that use a common database file to contain numerous individual tables.  In such cases, the Name property would hold the database name and the SubName property would hold the actual Table name.

Note

You will need SCR7 or higher to use SubName.


SubName property - See also
Related

Name

Path

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SubName property - Example
Example

The following example shows how to change the Name and SubName of a Table:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Tables.Retrieve;

  for cnt := 0 to (Crpe1.Tables.Count - 1) do

  begin

    Crpe1.Tables[cnt].Name := 'Northwind.mdb';

    Crpe1.Tables[cnt].SubName := 'Employees';

  end;

end;


ConnectBuffer property

See also	Example

Applies to

Tables

Declaration

property ConnectBuffer: string;

Description

The ConnectBuffer property is used to specify connection information when dealing with MSAccess attached tables.  ConnectBuffer is limited to 512 characters in length.


ConnectBuffer property - See also
Related

SubName

Name

Path

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ConnectBuffer property - Example
Example

The following example shows the use of ConnectBuffer when dealing with attached tables in Access:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Tables.Retrieve;

  for cnt := 0 to (Crpe1.Tables.Count - 1) do

  begin

    Crpe1.Tables[cnt].Path := 'D:\Office\Samples\';

    Crpe1.Tables[cnt].Name := 'Northwind.mdb';

    {An attached Dbase table}

    Crpe1.Tables[cnt].SubName := 'filmtype';

    {The ConnectBuffer specifies information about the attached table}

    Crpe1.Tables[cnt].ConnectBuffer := 'dBase III;HDR=NO;IMEX=2;-->D:\Scr7-->filmtype';

  end;

end;


Test method

See also	Example

Applies to

Tables

Declaration

function Test: boolean;

Description

The Test method can be used to check whether a Table can be connected to.  It returns a boolean result: True means a connection can be made to the Table with the current Path/Name/SubName information; False means a connection cannot be made to the Table.

To obtain a more detailed account of any connection problems, use the CheckDifferences method.


Test method - See also
Related

CheckDifferences

Name

SubName

Path

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Test method - Example
Example

This example illustrates the use of the Test method:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Retrieve;

for cnt := 0 to (Crpe1.Tables.Count - 1) do

begin

  Crpe1.Tables[cnt].Path := 'D:\Data';

  Crpe1.Tables[cnt].Name := 'Stats.dbf';

  if Crpe1.Tables[cnt].Test then

    ShowMessage('Table is good!')

  else

    ShowMessage('Table is not good!');

end;


CheckDifferences method

See also	Example

Applies to

Tables

Declaration

function CheckDifferences(var DifNums: TStringList; var DifStrings: TStringList): boolean;

Description

The CheckDifferences method analyzes the currently specified Table and compares it to what was specified in the Report to determine any differences that may cause problems when the Report is run.  Two stringlists are passed to the function call and any error numbers or strings are returned in the stringlists.  DifNums contains the error numbers and DifStrings contains the corresponding error strings.

A simpler and less-detailed method of checking the Tables is available via the Test method.

Note

CheckDifferences requires SCR7 (maintenance release version) or higher.


CheckDifferences method - See also
Related

Test

Name

SubName

Path

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CheckDifferences method - Example
Example

This example illustrates the use of the CheckDifferences method:

procedure TForm1.TablesCheck;

var

  slNums,

  slStrings : TStringList;

  i,j       : integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Tables.Retrieve;

  slNums := TStringList.Create;

  slStrings := TStringList.Create;

  for i := 0 to (Crpe1.Tables.Count - 1) do

  begin

    Crpe1.Tables[i].Path := 'D:\Data';

    Crpe1.Tables[i].Name := 'Stats.dbf';

    if not Crpe1.Tables[i].CheckDifferences(slNums, slStrings) then

      MessageDlg('Check Failed.', mtError, [mbOk], 0)

    else

    begin

      for j := 0 to slNums.Count - 1 do

        MessageDlg(slNums[j] + ': ' + slStrings[j], mtInformation, [mbOk], 0);

      slNums.Clear;

      slStrings.Clear;

    end;

  end;

  slNums.Free;

  slStrings.Free;

end;


IndexOf method

See also	Example

Applies to

Tables

Declaration

function IndexOf(TableNumber: TCrTableNumber): integer;

Description

The IndexOf method takes a Table number and returns the index position of the Table item in the Tables object.

After the Retrieve method has been called, the Tables object contains one item for each Table in the Report.  The IndexOf method can be used to determine if a given Table Number actually exists in the Tables object before trying to access it.


IndexOf method - See also
Related

Number

IndexOfName

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

This example shows how to use the IndexOf method to locate an item in the Tables object based on it's Table number value:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Retrieve;

i := Crpe1.Tables.IndexOf(2);

if i = -1 then

  ShowMessage('Table #' + IntToStr(i) + ' does not exist');


IndexOfName method

See also	Example

Applies to

Tables

Declaration

function IndexOfName(TableName: string): integer;

Description

IndexOfName can be used to check if a given Table Name exists in the Tables object after Retrieve has been called.


IndexOfName method - See also
Related

IndexOf

Name

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOfName method - Example
Example

This example shows how to use the IndexOfName method to locate an item in the Tables object based on its Name:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Tables.Retrieve;

i := Crpe1.Tables.IndexOf('Stats.dbf');

if i = -1 then

  ShowMessage('"Stats.dbf" does not exist in this Report!');


ParamFields

See also	Properties & Methods	Example

Declaration

property ParamFields: TCrpeParamFields;

Types

TCrpeParamFields = class(TPersistent)

Description

The ParamFields object contains all the properties that apply to Parameter Fields.  For Seagate Crystal Reports 7, ParamFields have been greatly expanded.  The new features are documented at the bottom of this description, in the section New Features for SCR 7.  Read it!

•	The Name property specifies the actual Parameter name, as defined in the Report, and acts as a lookup field.

•	The default array property Item, and the ItemIndex property can be used to navigate through the various ParamField items (assuming there is more than one Parameter in the Report).

•	The Value property holds the actual parameter value that is to be passed to the Parameter Field.  Values are passed as strings, but are converted within the VCL to the correct Parameter Type required for the particular Parameter field.  There are six other properties that can be used to read and write the Value property using native Delphi types:

AsNumber

AsCurrency

AsBoolean

AsDate

AsDateTime	//SCR 7.0 and higher

AsTime 	//SCR 7.0 and higher

•	If the Retrieve method is used to get Parameter Field information from the Report, the ParamType property will show what type each Parameter is.  The RetrieveValues method is used to obtain CurrentValues and DefaultValues, which are not obtained via the normal Retrieve method.

•	The Prompt property specifies the prompting text that appears on the Crystal Reports Parameter prompt dialog.

•	The ShowDialog property specifies whether the Value passed in will bypass the Parameter prompt dialog, or whether it will show up as the new default value in the Parameter prompt dialog.

•	The ReportName property is read-only and specifies which Report the Parameter belongs to.  Parameters are handled slightly differently than other Report properties.  When the ParamFields are retrieved for the main Report, the resulting list contains all of the Parameter Fields in the Report, including those in Subreports.  This is because when the main Report is run, the prompt dialog contains all of the Parameters (main & sub), and so they are considered as being partly "owned" by the main Report.  Therefore, ReportName indicates which Subreport the Parameter belongs to.

•	The NeedsCurrentValue property is a read-only and specifies whether the Parameter actually requires a value or not.  If the Parameter is linked to a Subreport, or is not used in the Report, then NeedsCurrentValue will be False.

Here are some examples which show how to pass each Parameter type:

ParamType	Value	As[Type]	Delphi Type

pfNumber	'235'	AsNumber := 235	double

pfCurrency	'2.35'	AsCurrency := 2.35	currency

pfBoolean	'True'	AsBoolean := True	boolean

pfDate	'1997,01,30'	AsDate := EncodeDate(1997,01,30)	TDateTime

pfString	'Vancouver'	Value := 'Vancouver'	string

pfDateTime	'1997,01,30 1:12:14'	AsDateTime := StrToDateTime('01/30/97 1:12:14')	TDateTime

pfTime	'1:12:14'	AsTime := EncodeTime(1,12,14,0)	TDateTime

Note

When running a Report, always retrieve and set the ParamFields from the main Report.  The only time it is necessary to retrieve ParamFields for a Subreport specifically, is when that Subreport is going to be run as a separate Report, apart from the main Report (see Subreports for more information on running a Subreport).

New Features for SCR 7

For Seagate Crystal Reports 7, the following main features have been added to the ParamFields class:

1. Stored Procedure Parameters are now handled through the ParamFields class instead of the SQL.Params class, as with the previous Crystal versions and the last VCL release.  For this purpose, there is now a ParamSource property which specifies the source of the Parameter, whether it is a Crystal Reports Parameter Field, a Stored Procedure Parameter, or a Crystal Query Parameter.

2. ParamField prompts can now have a drop-down list of values, multiple values, a range of values, multiple ranges of values:

•	The DefaultValues property is a TCrpeString (descendant of TStringList) which contains the multiple values that are to be presented in the Crystal Reports Parameter Field prompt dialog.  If ShowDialog is set to true, the DefaultValues data takes precedence over the data contained in the Value property (ie. DefaultValues[0] will over-ride Value if they are different).

•	The CurrentValues property is a TCrpeString (descendant of TStringList) which contains the multiple values that were entered in the Crystal Reports Parameter Field prompt dialog.  This list will initially be blank unless the Report has been run already once (and then Retrieve is called after running the Report), or if the Report has Saved Data (see DiscardSavedData for more information).  If ShowDialog is set to true, CurrentValues will not be used.  If ShowDialog is set to False, and Info.ValueType is vtDiscrete, CurrentValues data will take precedence over the data contained in the Value property (ie. CurrentValues[0] will over-ride Value if they are different).

•	A Ranges sub-class has been added under the ParamFields class.  This sub-class contains the properties that apply to Range Parameters (parameters that can take begining and ending range values).  This object only comes into play if you are passing range values direct to the Report, bypassing Crystal's Parameter prompt dialog, or if you wish to view the Range values that were either saved with the Report (if the Report has Saved Data), or that were entered when the Report was just run.  In order to use Ranges, ShowDialog must be set to False, and Info.ValueType must be set to vtRanges.  In this case, the Ranges data will take precedence over the data contained in the Value property.

3. An EditMask can be specified to control the formatting of values that are entered into the Crystal Reports Parameter Field dialog box for a particular Parameter.

4. Limits can be set to the length or size of the value that can be entered into the Crystal Reports Parameter Field dialog box for a particular Parameter.  This is handled by three properties: ValueLimit, ValueMax, and ValueMin.  ValueLimit determines if the Limit feature is enabled or not.  ValueMax and ValueMin determine the upper and lower limits.  If the Parameter is a string, the limits apply to the length of the string.  If the Parameter is any other type, the limits apply to the maximum and minimum values that can be entered.  Limits and EditMask are mutually exclusive.  If you define an EditMask, Limits will be ignored.

5. A Parameter Fields Info sub-class has been added under the ParamFields class.  This sub-class contains various properties that specify whether the Parameter can be edited, whether it can have null values (for Stored Procedure Parameters), whether it can contain multiple values, whether it is a Range Parameter, and whether it belongs to a group (and if so, which group number).


ParamFields - See also
Related

Info

Ranges

Formulas

Selection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ParamFields - Properties & Methods
ParamFields:

Properties & Methods

ParamFields	TCrpe Component

Properties

CurrentValue

CurrentValues

DefaultValue

DefaultValues

Value

Prompt

ShowDialog

Key

Name

Parameter Information

NeedsCurrentValue

ParamSource

ParamType

ReportName

Conversion

AsBoolean

AsCurrency

AsDate

AsDateTime

AsNumber

AsTime

ValueLimits/EditMask

EditMask

ValueLimit

ValueMax

ValueMin

Navigation

Item

ItemIndex

ParamField Info

Info

ParamField Ranges

Ranges

PickLists

PickList

PLDescriptionOnly

PLSortByDescription

PLSortMethod

Methods

Clear

CopyFrom

Count

IndexOf

Retrieve

RetrieveValues

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


ParamFields - Example
Example

The following code fills a ListBox with all the ParamField Names for the current Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

for cnt := 0 to (Crpe1.ParamFields.Count - 1) do

  ListBox1.Items.Add(Crpe1.ParamFields[cnt].Name);

This example illustrates the Value and AsDate, etc. properties to set Parameter Field values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Value := 'CA';

Crpe1.ParamFields[1].AsDate := Now;

Crpe1.ParamFields[2].AsNumber := 3;

Crpe1.ParamFields[3].AsBoolean := True;

Crpe1.Output := toWindow;

Crpe1.Execute;

This example sets 3 default values for the first ParamField that will appear in the drop-down list when the Crystal Parameter prompt dialog appears.  The user will only be able to choose from these values, they cannot enter new ones (AllowEditing is false):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].DefaultValues.Clear;

Crpe1.ParamFields[0].DefaultValues[0] := 'AK';

Crpe1.ParamFields[0].DefaultValues[1] := 'CA';

Crpe1.ParamFields[0].DefaultValues[2] := 'WA';

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.ParamFields[0].Info.AllowEditing := False;

Crpe1.Output := toWindow;

Crpe1.Execute;

This example sets 2 Range values for the first ParamField.  These will be passed directly into the Report, bypassing the Crystal Parameter prompt dialog:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Info.ValueType := vtRanges;

Crpe1.ParamFields[0].ShowDialog := False;

Crpe1.ParamFields[0].Ranges.Clear;

Crpe1.ParamFields[0].Ranges.Add(0);

Crpe1.ParamFields[0].Ranges[0].RangeStart := 'Atkinson';

Crpe1.ParamFields[0].Ranges[0].RangeEnd := 'Jones';

Crpe1.ParamFields[0].Ranges[0].RangeBounds := IncludeStartAndEnd;

Crpe1.ParamFields[0].Ranges.Add(1);

Crpe1.ParamFields[0].Ranges[1].RangeStart := 'Smith';

Crpe1.ParamFields[0].Ranges[1].RangeEnd := 'Wilson';

Crpe1.ParamFields[0].Ranges[1].RangeBounds := IncludeStartAndEnd;

Crpe1.Output := toWindow;

Crpe1.Execute;


Item property

See also	Example

Applies to

ParamFields

Declaration

property Item[const nIndex: integer]: TCrpeParameterFields;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the ParamFields object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  ParamFields[2] is the same as ParamFields.Item[2].

•	Item returns a reference to the ParamFields object, so the ParamFields properties can be used right after the subscript: ParamFields[2].Value := '100';


Item property - See also
Related

ItemIndex

Name

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{Set ParamFields to the 3rd Parameter field}

Crpe1.ParamFields.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{Set ParamFields to the 3rd Parameter field}

Crpe1.ParamFields[2];


ItemIndex property

See also	Example

Applies to

ParamFields

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current ParamFields item number, or set the ParamFields object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (ParamFields[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

Name

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the ParamFields object is pointing to the first ParamFields item:

if Crpe1.ParamFields.ItemIndex <> 0 then

  Crpe1.ParamFields[0];


Name property

See also	Example

Applies to

ParamFields

Declaration

property Name: TCrParamFieldName;

Types

TCrParamFieldName = string;

Description

The Name property is the key property for the ParamFields sub-class.  It contains the Name of the Parameter Field.  It is a look-up property and therefore cannot be directly written to.  If the Retrieve method is used, the Name property is automatically filled when the ParamFields are retrieved and when the ParamFields object is pointed to one of the retrieved items.  To write to it indirectly, use the Add method.

•	When the Name property is changed, all of the properties of the ParamFields object are updated to look at that particular ParamField.

•	The Parameter Name is limited to 255 characters (anything greater than that will be truncated).

Note

It is also possible, and often easier, to navigate through the various ParamFields items by using the default array property Item, or the ItemIndex property.


Name property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Name property - Example
Example

This example illustrates the use of the Name property to navigate through the ParamFields object:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{Set ParamFields object to item 'FirstParam' name}

Crpe1.ParamFields.Name := 'FirstParam';

{Set ParamFields item Value}

Crpe1.ParamFields.Value := 'CA';

Crpe1.Output := toWindow;

Crpe1.Execute;

Note that since there is an internal index in the ParamFields object (and most of the other Crystal VCL sub-class objects), it is not necessary to specify a subscript (ie. ParamFields[0].Value) every time a property is set.  Once the sub-class object is pointing to a certain item, the other properties apply to that item, whether the subscript is specified or not.


NeedsCurrentValue property

See also	Example

Applies to

ParamFields

Declaration

property NeedsCurrentValue: boolean;

Description

NeedsCurrentValue is a read-only property that will only have a meaningful value if the Retrieve method is used to fetch the ParamField items from the Report.  It indicates whether a ParamField item requires a value or not.  Any ParamFields that are created as a result of a Subreport link, or that are not used in the Report, will return False for NeedsCurrentValue.  These ParamFields do not require values, and will not prompt for values when a Report is run.


NeedsCurrentValue property - See also
Related

Value

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NeedsCurrentValue property - Example
Example

This example checks the NeedsCurrentValue property before assigning a ParamField Value:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ParamFields.Retrieve;

  for cnt := 0 to (Crpe1.ParamFields.Count - 1) do

  begin

    if Crpe1.ParamFields[cnt].NeedsCurrentValue = True then

      Crpe1.ParamFields[cnt].Value := 'CA';

  end;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


ParamType property

See also	Example

Applies to

ParamFields

Declaration

property ParamType: TCrParamFieldType;

Types

TCrParamFieldType = (pfNumber, pfCurrency, pfBoolean, pfDate, pfString, pfDateTime, pfTime, pfInteger, pfColor, pfChar, pfLong, pfNoValue);

Description

ParamType is a read-only property that will only have a meaningful value if the Retrieve method is used to obtain ParamFields items from the Report.  It indicates what data type the Value property is expecting.

Note

It is not possible to change the type of a ParamField at runtime.  This must be done within the Crystal Reports designer.


ParamType property - See also
Related

Value

AsBoolean

AsCurrency

AsDate

AsNumber

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ParamType property - Example
Example

The ParamType property can be used to check the type of Value the ParamField item expects:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

for cnt := 0 to (Crpe1.ParamFields.Count - 1) do

begin

  case Crpe1.ParamFields[cnt].ParamType of

    pfNumber   : Crpe1.ParamFields[cnt].AsNumber := 1;

    pfCurrency : Crpe1.ParamFields[cnt].AsCurrency := 1.23;

    pfBoolean  : Crpe1.ParamFields[cnt].AsBoolean := True;

    pfDate     : Crpe1.ParamFields[cnt].AsDate := Now;

    pfString   : Crpe1.ParamFields[cnt].Value := 'CA';

  end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


Prompt property

See also	Example

Applies to

ParamFields

Declaration

property Prompt: string;

Description

The Prompt property specifies the prompting text, if any, that will appear on the Parameter Prompt dialog box.  This will be either the prompting text assigned when the Parameter field was first inserted into the Report, or the prompting text  that was set from code.

If the ShowDialog property is false, then the Prompt dialog box will not appear, so there is no need, in that case, to set the Prompt property.


Prompt property - See also
Related

ShowDialog

Value

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Prompt property - Example
Example

This example changes the Prompt property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.ParamFields[0].Prompt := 'Enter the State:';

Crpe1.ParamFields[0].Value := 'CA';

Crpe1.Output := toWindow;

Crpe1.Execute;


ReportName property

See also	Example

Applies to

ParamFields

Declaration

property ReportName: TCrParamFieldReportName;

Type

TCrParamFieldReportName = string;

Description

ReportName is a runtime, read-only property that specifies which Report the Parameter applies to.  It will only contain a meaningful value if the Retrieve method is used to fetch the ParamFields items.  Any Parameters that apply to the main Report will have a blank value for ReportName.

•	The ReportName is limited to 128 characters (anything greater than that will be truncated).

Note

For Subreports, the ReportName property holds the same value as the ReportTitle and Subreports.Name properties.  If the ReportTitle for a Subreport is changed, it is recommended that the Subreports and ParamFields objects be cleared and reloaded before attempting to run the Report twice in a row.


ReportName property - See also
Related

ReportTitle

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ReportName property - Example
Example

In this example, because there are two Parameter fields with the same name (one in the main Report and one in the Subreport), the ReportName property is checked to distinguish the ParamFields:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ParamFields.Retrieve;

  for cnt := 0 to Crpe1.ParamFields.Count - 1 do

  begin

    if Crpe1.ParamFields[cnt].ReportName = 'Sub1' then

      Crpe1.ParamFields[cnt].Value := 'CA'

    else

      Crpe1.ParamFields[cnt].Value := 'WA';

  end;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


ShowDialog property

See also	Example

Applies to

ParamFields

Declaration

property ShowDialog: boolean;

Description

The ShowDialog property determines if the Parameter prompt dialog will appear or not.  There are two ways to use Parameter Fields at runtime:

1. Pass a value directly into the Parameter without seeing the Parameter prompt dialog.  In this case, ShowDialog should be set to False.

2. Change the default value that the Parameter contains, but show the Parameter prompt dialog anyway to allow the user to change it.  In this case, ShowDialog should be set to True.

The default value for ShowDialog is False.


ShowDialog property - See also
Related

Prompt

Value

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ShowDialog property - Example
Example

In the example below, one Parameter field will not be prompted for, and the other one will.  When the prompt dialog appears, 'WA' will be the default value:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{Change value and do not prompt for this one}

Crpe1.ParamFields[0].Value := 'CA';

Crpe1.ParamFields[0].ShowDialog := False;

{Change value but prompt for this one}

Crpe1.ParamFields[1].Value := 'WA';

Crpe1.ParamFields[1].ShowDialog := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


Value property

See also	Example

Applies to

ParamFields

Declaration

property Value: string;

Description

The Value property specifies the value that is to be passed into the Parameter field.  This must be formatted as a string, regardless of the ParamType.  Here are some examples which show how to pass each Parameter type:

ParamType	Value

pfNumber	'235'

pfCurrency	'2.35'

pfBoolean	'True'

pfDate	'1997,01,30'	{YYYY,MM,DD}

pfString	'Vancouver'

pfDateTime	'1997,01,30 1:12:14'	{YYYY,MM,DD HH:MM:SS}   {SCR 7 only}

pfTime	'1:12:14'	{HH:MM:SS}   {SCR 7 only}

There are six other properties that can be used to read and write the Value property using native Delphi types:  AsNumber, AsCurrency, AsBoolean, AsDate, AsDateTime, AsTime.

Note

With SCR 7, multiple default and current values can be passed as Parameters.  A default value is one that will appear in the Parameter prompt dialog for possible selection by the user.  A current value is one that is a Parameter value that has already been selected and passed into a Report Parameter, either by the programming front-end, or by the user selecting an item in the Parameter dialog.

With the previous release of the VCL, we were only concerned with the Value property, and if the ShowDialog property was set to True, the Value property was passed to the Report as a default value; if the ShowDialog property was set to False, the Value property was passed into the Report as a current value.

However, with this new release, since we can have multiple default and current values, a simple string property was not good enough to handle this.  So two new StringList properties were added: DefaultValues and CurrentValues.  If the DefaultValues or CurrentValues properties of the ParamFields object have values in them, these will take precedence over what may be stored or set in the Value property.


Value property - See also
Related

AsBoolean

AsCurrency

AsDate

AsNumber

AsDateTime

AsTime

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Value property - Example
Example

This example illustrates the Value and AsDate, etc. properties to set Parameter Field values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Value := 'CA';

Crpe1.ParamFields[1].AsDate := Now;

Crpe1.ParamFields[2].AsNumber := 3;

Crpe1.ParamFields[3].AsBoolean := True;

Crpe1.ParamFields[4].AsCurrency := 1.23;

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

ParamFields

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the ParamFields object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

ParamFields

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

ParamFields

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the ParamFields object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.ParamFields.Retrieve;

  for cnt := 0 to (Crpe1.ParamFields.Count - 1) do

    Crpe1.ParamFields[cnt].Value := 'CA';

end;


Retrieve method

See also	Example

Applies to

ParamFields

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Parameter Field information from the Report and adds one item to the ParamFields object for each Parameter in the Report.  If Parameter Fields were not found, the call returns False.  Be aware that calling Retrieve will first cause the ParamFields object to be cleared, so any current information stored in it will be removed.  Retrieve will no longer retrieve the DefaultValues and CurrentValues for a ParamField.  These are now handled in the new RetrieveValues method.

Retrieving from the Main Report

ParamFields are treated slightly differently by the Print Engine than most of the other properties.  Calling Retrieve for the main Report will return all the ParamFields from the main Report, as well as all the ParamFields from any Subreports.  This is because Parameter fields are considered in a certain sense to be part of the main Report, since refreshing the main Report in Crystal Reports will cause the Parameter prompt dialog to display all of the Parameters that require values, whether they are located in the main Report, or in a Subreport.

When retrieving ParamFields for a main Report, any Parameters in a Subreport, that are linked to the main Report, will still be retrieved, but the NeedsCurrentValue property will read False, which means that these Parameter fields do not require values to be set in code, since they will obtain their values from the link to the main Report, when the Report is run.

Retrieving from a Subreport

In most cases, you will want to work with the Parameters as returned in the main Report ParamFields object.  However, if you are going to be running Subreports separate from the main Report (see SubExecute), the ParamFields should be retrieved for that Subreport specifically.  In other words, the Subreports object should be pointing to the Subreport that is going to be run, before Paramfields.Retrieve is called.  This will cause the ParamFields object for that Subreport to be filled with information on the Parameter fields that apply specifically to that Subreport.  In such a case, any Parameter fields that are linked to the main Report will appear as unlinked, since they are expecting a value, and will not be getting the value from the main Report when the Subreport is run as stand-alone.  (Note that the initial release of Crystal Reports 7 runtime causes an Access Violation when trying to retrieve Parameters from a Subreport when the Subreport Job is currently active).


Retrieve method - See also
Related

RetrieveValues

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code will retrieve all the Parameter fields in a Report, whether they are in a main Report or a Subreport.  Note that ParamFields behave slightly differently in this respect than other objects:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the ParamFields}

Crpe1.ParamFields.Retrieve;

The next example shows how to retrieve only the Parameter fields that apply to a specific Subreport.  This should only be necessary if the Subreport is going to be run as a stand-alone Report, separate from the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Subreports items}

Crpe1.Subreports.Retrieve;

{Allow Subreports to be run stand-alone}

Crpe1.Subreports.SubExecute := True;

{Set the Crpe to point to the 2nd Subreport}

Crpe1.Subreports[2];

{Retrieve the ParamFields for the 2nd Subreport}

Crpe1.ParamFields.Retrieve;


Send method

See also	Example

Applies to

ParamFields

Declaration

function Send: boolean;

Description

The Send method sends the ParamFields values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the ParamFields settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.ParamFields.Send;


Add method

See also	Example

Applies to

ParamFields

Declaration

function Add(ParameterName: TCrParameterFieldName; ReportName: TCrParamFieldReportName): integer;

Type

TCrParameterFieldName = string;

TCrParamFieldReportName = string;

Description

The Add method adds an item to the ParamFields object and sets the internal index to that item.  It requires a Parameter Field name and a Report Name as parameters, which should correspond to a Parameter Field Name in the Report and a valid Report Name (the Main Report does not have a Report Name -- use an empty string).

If the Add method is used instead of Retrieve, the steps to using ParamFields are:

1. Add an item to the ParamFields object (you must specify the Parameter Field name and Report Name).

2. Fill the item's properties (Value, Prompt, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

•	The ParameterName is limited to 255 characters (anything greater than that will be truncated).

•	The ReportName is limited to 128 characters (anything greater than that will be truncated).

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Parameter numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the ParamFields object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Parameter Name - must be same as in Report}

Crpe1.ParamFields.Add('Parameter1');

Crpe1.ParamFields.Value := 'CA';

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

ParamFields

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the ParamFields object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the ParamFields object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the ParamFields of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear:

for cnt := 0 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.ParamFields.Clear;

end;


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the ParamFields properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.ParamFields.Clear;

This code clears the ParamFields properties for the second Subreport:

Crpe1.Subreports[2];

Crpe1.ParamFields.Clear;


Delete method

See also	Example

Applies to

ParamFields

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the ParamFields object.  The "nIndex" parameter represents the number of the item in the ParamFields object.

Note

Delete will not remove the Parameter Field from the Report, it will just remove it from the Crystal VCL.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the ParamFields object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Parameter Name - must be same as in Report}

Crpe1.ParamFields.Add('Parameter1');

Crpe1.ParamFields.Value := 'CA';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.ParamFields.Delete(0);


AsNumber property

See also	Example

Applies to

ParamFields

Declaration

property AsNumber: double;

Description

The AsNumber property is run-time only and can be used to read and write the ParamFields.Value property with native Delphi number values.  Whereas the Value property holds the ParamFields value as a string, AsNumber will return the value as a number type, or can be written to with a number type.


AsNumber - See also
Related

Value

AsBoolean

AsCurrency

AsDate

AsDateTime

AsTime

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsNumber - Example
Example

This example uses the AsNumber property to pass in a native Delphi number variable to the ParamFields Value property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].AsNumber := 1;

Crpe1.Execute;


AsCurrency property

See also	Example

Applies to

ParamFields

Declaration

property AsCurrency: currency;

Description

The AsCurrency property is run-time only and can be used to read and write the ParamFields.Value property with native Delphi currency values.  Whereas the Value property holds the ParamFields value as a string, AsCurrency will return the value as a currency type, or can be written to with a currency type.


AsCurrency - See also
Related

Value

AsBoolean

AsDate

AsNumber

AsDateTime

AsTime

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsCurrency - Example
Example

This example uses the AsCurrency property to pass in a native Delphi currency variable to the ParamFields Value property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].AsCurrency := 1.23;

Crpe1.Execute;


AsBoolean property

See also	Example

Applies to

ParamFields

Declaration

property AsBoolean: boolean;

Description

The AsBoolean property is run-time only and can be used to read and write the ParamFields.Value property with native Delphi boolean values.  Whereas the Value property holds the ParamFields value as a string, AsBoolean will return the value as a boolean type, or can be written to with a boolean type.


AsBoolean - See also
Related

Value

AsCurrency

AsDate

AsNumber

AsDateTime

AsTime

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsBoolean - Example
Example

This example uses the AsBoolean property to pass in a native Delphi boolean variable to the ParamFields Value property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].AsBoolean := True;

Crpe1.Execute;


AsDate property

See also	Example

Applies to

ParamFields

Declaration

property AsDate: TDateTime;

Description

The AsDate property is run-time only and can be used to read and write the ParamFields.Value property with native Delphi DateTime values.  Whereas the Value property holds the ParamFields value as a string, AsDate will return the value as a datetime type, or can be written to with a datetime type.


AsDate - See also
Related

Value

AsBoolean

AsCurrency

AsNumber

AsDateTime

AsTime

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsDate - Example
Example

This example uses the AsDate property to pass in a native Delphi datetime variable to the ParamFields Value property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].AsDate := Now;

Crpe1.Execute;


DefaultValue property

See also	Example

Applies to

ParamFields

Declaration

property DefaultValue: string

Description

The DefaultValue property indicates the Default Prompting Value that was entered for a Parameter Field when the Parameter was created in Crystal Reports.

•	The Retrieve method must be used first, before DefaultValue will contain anything.

•	The DefaultValue is automatically copied to the Value property when the Retrieve method is called.

•	If the Report has already been run at least once, and the ShowDialog property was set to True, DefaultValue will indicate the value that appeared (before being edited) in the Parameter Prompt dialog (Note that in this case, Retrieve must be called again after the Report has been run in order to show the last default value).

Note

DefaultValue is included primarily as a reference property, and is not used when the ParamFields are sent to the Print Engine, so changes to it will not be reflected when the Report is run.  Instead, any changes desired should be made to the Value property.

New Features for SCR 7.0

With Seagate Crystal Reports 7.0, multiple Default Values are possible for a Parameter Field.  These are handled via the DefaultValues property, which is a StringList.


DefaultValue property - See also
Related

Value

DefaultValues

CurrentValue

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DefaultValue property - Example
Example

This example displays the DefaultValue for the first ParamField:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

ShowMessage(Crpe1.ParamFields[0].DefaultValue);


CurrentValue property

See also	Example

Applies to

ParamFields

Declaration

property CurrentValue: string

Description

The CurrentValue property indicates the Parameter Value that was last entered into the Parameter Field Prompt Dialog.

•	The Retrieve method must be used first, before CurrentValue will contain anything.

•	If the Report does not have Saved Data, CurrentValue will be an empty string until the Report is run at least once (Note that in this case, Retrieve must be called again after the Report has been run in order to show the last value sent to the Parameter Field).

Note

CurrentValue is included primarily as a reference property, and is not used when the ParamFields are sent to the Print Engine, so changes to it will not be reflected when the Report is run.  Instead, any changes desired should be made to the Value property.

New Features for SCR 7.0

With Seagate Crystal Reports 7.0, multiple Current Values are possible for a Parameter Field.  These are handled via the CurrentValues property, which is a StringList.


CurrentValue property - See also
Related

Value

CurrentValues

DefaultValue

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CurrentValue property - Example
Example

This example copies the CurrentValue to the Value property for the first ParamField.  This only makes sense if the Report has already been run once, or it has Saved Data:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Value := Crpe1.ParamFields[0].CurrentValue;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


AsDateTime property

See also	Example

Applies to

ParamFields

Declaration

property AsDateTime: TDateTime;

Description

The AsDateTime property is a run-time property that allows for reading and writing of the Value property (which is a string type) using native Delphi TDateTime values.  This property should only be used if the ParamField is actually specified as DateTime (the ParamType is pfDateTime).


AsDateTime property - See also
Related

Value

AsBoolean

AsCurrency

AsDate

AsNumber

AsTime

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsDateTime property - Example
Example

This example uses the AsDateTime property to pass in a native Delphi datetime variable to the ParamFields Value property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].AsDateTime := Now;

Crpe1.Execute;


AsTime property

See also	Example

Applies to

ParamFields

Declaration

property AsTime: TDateTime;

Description

The AsTime property is run-time only and can be used to read and write the ParamFields.Value property with native Delphi DateTime values.  Whereas the Value property holds the ParamFields value as a string, AsTime will return the value as a datetime type, or can be written to with a datetime type.


AsTime property - See also
Related

Value

AsBoolean

AsCurrency

AsDate

AsNumber

AsDateTime

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsTime property - Example
Example

This example uses the AsTime property to pass in a native Delphi datetime variable to the ParamFields Value property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].AsTime := Now;

Crpe1.Execute;


CurrentValues property

See also	Example

Applies to

ParamFields

Declaration

property CurrentValues: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

CurrentValues is a StringList that contains multiple values that are to be passed to a Crystal Parameter Field.  CurrentValues will only apply if the ParamField.Info.ValueType = vtDiscrete.  Otherwise, the Ranges sub-class will apply.

Assuming that the Info.ValueType is vtDiscrete, when the RetrieveValues method of the ParamFields object is called, the CurrentValues stringlist will contain any current values that have been set for the current item in the ParamFields object.  Normally there would not be any, unless the Report has Saved Data, or it has just been run once already.

The most common use of CurrentValues would be to pass multiple values into a ParamField when the Parameter prompt dialog is going to be bypassed.  In this case, the values should be added to the CurrentValues stringlist, and the ShowDialog property should be set to False.  Note that if the ParamField.Info.AllowMultipleValues property is False, only the first item in the CurrentValues stringlist will be used in the Report.  On the other hand, if AllowMultipleValues is true, then all the values will be used in the Report.  In this case, the Report must be designed to handle a ParamField which has an array of values in it (see the CRW.HLP for information on using arrays in formulas).

To clear the CurrentValues or DefaultValues from a Report, the CrEmptyStr constant should be used, since clearing the Current or Default Values properties in the VCL will cause them to be ignored when the ParamFields are sent to the Print Engine:

{Clear the first Parameter's CurrentValues from the Report}

Crpe1.ParamFields[0].CurrentValues.Text := CrEmptyStr;

{Clear the first Parameter's DefaultValues from the Report}

Crpe1.ParamFields[0].DefaultValues.Text := CrEmptyStr;

Note

To read and write CurrentValues using native Delphi types (boolean, currency, datetime, etc.), use the following methods (in the UCrpeUtl unit):

Reading

CrStrToBoolean

CrStrToDate

CrStrToDateTime

CrStrToFloating

CrStrToTime

Writing

CrBooleanToStr

CrDateTimeToStr

CrDateToStr

CrFloatingToStr

CrTimeToStr

Extracting Parts

ExDateStr

ExDateTimeStr

ExTimeStr


CurrentValues property - See also
Related

RetrieveValues

DefaultValues

Value

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CurrentValues property - Example
Example

This example sets 2 CurrentValues for the first ParamField.  These will be passed directly into the Report, bypassing the Crystal Parameter prompt dialog:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{Allow more than one value, ie. an array}

Crpe1.ParamFields[0].Info.AllowMultipleValues := cTrue;

Crpe1.ParamFields[0].ShowDialog := False;

{Retrieve the CurrentValues...}

Crpe1.ParamFields[0].RetrieveValues;

{Add two more items to the CurrentValues list...}

Crpe1.ParamFields[0].CurrentValues.Add('Atkinson');

Crpe1.ParamFields[0].CurrentValues.Add('Jones');

Crpe1.Output := toWindow;

Crpe1.Execute;


DefaultValues property

See also	Example

Applies to

ParamFields

Declaration

property DefaultValues: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

DefaultValues is a StringList that contains multiple values that are to be passed as possible choices to a Crystal Parameter Field.  These values will not actually be used in the Parameter until the user selects them when the Parameter prompt dialog appears.  If you do not want the Parameter prompt dialog to appear, you should use the CurrentValues property instead.

When the RetrieveValues method of the ParamFields object is called, the DefaultValues stringlist will contain any default values that have been entered as options for the currently selected ParamField item.  Normally this would have been done when the Parameter was created in the Report, but could also be those items that were sent in as default values from a previous run of the Report (provided the Report is still in memory).

The most common use of DefaultValues would be to edit or add to the list of multiple values that will be available for the user to choose from when the Parameter prompt dialog appears.  In this case, the ShowDialog property should be set to True.

To clear the CurrentValues or DefaultValues from a Report, the CrEmptyStr constant should be used, since clearing the Current or Default Values properties in the VCL will cause them to be ignored when the ParamFields are sent to the Print Engine:

{Clear the first Parameter's CurrentValues from the Report}

Crpe1.ParamFields[0].CurrentValues.Text := CrEmptyStr;

{Clear the first Parameter's DefaultValues from the Report}

Crpe1.ParamFields[0].DefaultValues.Text := CrEmptyStr;

Note

To read and write DefaultValues using native Delphi types (boolean, currency, datetime, etc.), use the following methods:

Reading

CrStrToBoolean

CrStrToDate

CrStrToDateTime

CrStrToFloating

CrStrToTime

Writing

CrBooleanToStr

CrDateTimeToStr

CrDateToStr

CrFloatingToStr

CrTimeToStr

Extracting Parts

ExDateStr

ExDateTimeStr

ExTimeStr


DefaultValues property - See also
Related

RetrieveValues

CurrentValues

PickList

Value

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DefaultValues property - Example
Example

This example adds 2 DefaultValues to the first ParamField.  These will be offered as choices when the Parameter prompt dialog appears:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].ShowDialog := True;

{Retrieve the DefaultValues}

Crpe1.ParamFields[0].RetrieveValues;

Crpe1.ParamFields[0].DefaultValues.Add('Atkinson');

Crpe1.ParamFields[0].DefaultValues.Add('Jones');

Crpe1.Output := toWindow;

Crpe1.Execute;


EditMask property

See also	Example

Applies to

ParamFields

Declaration

property EditMask: string;

Description

The EditMask property can be used to control the type of data that can be input into the Crystal Parameter prompt dialog's edit field.  It is only applicable to string-type parameters (ParamType = pfString).

The EditMask can be any of a set of masking characters used to restrict the values that can be entered.  Some of the Edit Mask characters require that a character be entered in their place, while others are optional placeholders, and still others act as separator characters.

For example, if the EditMask is 000099, a parameter value with four digits, five digits, or six digits can be entered by the user, since the "9" EditMask character does not require the entry of a character. However, since "0" does require such an entry, a parameter value with less than four digits cannot be entered.

A	- allows an alphanumeric character and requires the entry of a character in the parameter value.

a	- allows an alphanumeric character and does not require the entry of a character in the parameter value.

0	- allows a digit [0 to 9] and requires the entry of a character in the parameter value.

9	- allows a digit or a space, and does not require the entry of a character in the parameter value.

#	- allows a digit, space, or plus/minus sign, and does not require the entry of a character in the parameter value.

L	- allows a letter [A to Z], and requires the entry of a character in the parameter value.

?	- allows a letter, and does not require the entry of a character in the parameter value.

&	- allows any character or space, and requires the entry of a character in the parameter value.

C	- allows any character or space, and does not require the entry of a character in the parameter value.

.,:;-/	- separator characters.

Inserting separator characters into the EditMask is similar to hard coding the formatting for the Parameter field. When the field is placed on the report, the separator character will appear in the field object frame, like this: LLLL/0000. This example depicts an edit mask that requires four letters followed by four numbers.

<	- causes subsequent characters to be converted to lowercase.

>	- causes subsequent characters to be converted to uppercase.

\	- causes the subsequent character to be displayed as a literal. For example, the Edit Mask "\A" would display a parameter value of "A." If the Edit Mask is "00\A00," then a valid parameter value would consist of two digits, the letter "A," and then two additional digits.

Password	- if the EditMask is set to "Password", the Parameter prompt dialog will show only "****" characters in the edit field.  In this way, conditional formulas can be created specifying that certain sections of the report will be visible only when certain user passwords are entered.

Note

EditMask is limited to 256 characters in length (anything greater than that will be truncated).


EditMask property - See also
Related

ValueLimit

ValueMax

ValueMin

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


EditMask property - Example
Example

This example sets an EditMask for the first ParamField, "parameter1".  The mask is to be used for a State abbreviation, "CA", "WA", etc:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].ShowDialog := True;

{Requires two letters, they will be converted to uppercase}

Crpe1.ParamFields[0].EditMask := '>LL';

Crpe1.Selection.Formula.Text := '{company.STATE} = {?parameter1}';

Crpe1.Output := toWindow;

Crpe1.Execute;


Info - See 7000


ParamSource property

See also	Example

Applies to

ParamFields

Declaration

property ParamSource: TCrParamFieldSource;

Type

TCrParamFieldSource = (psReport, psStoredProc, psQuery);

Description

The ParamSource property is a read-only property that reveals the source of the Parameter.  With the release of SCR 7, the ParamFields class now handles Crystal Reports Parameter Fields, Stored Procedure Parameters, and Crystal Query Parameter Fields, and this property provides a way to distinguish between them.  The Retrieve method must be called before this property will have a meaningful value.


ParamSource property - See also
Related

ParamType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ParamSource property - Example
Example

This example feeds all the Stored Procedure Parameter names to a ListBox::

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

for cnt := 0 to (Crpe1.ParamFields.Count - 1) do

begin

if Crpe1.ParamFields[cnt].ParamSource = psStoredProc then

  ListBox1.Items.Add(Crpe1.ParamFields[cnt].Name);

end;

end;


Ranges - See 7800
see 7800


ValueLimit property

See also	Example

Applies to

ParamFields

Declaration

property ValueLimit: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The ValueLimit, ValueMin, and ValueMax properties work together.  They provide a way of limiting the input in the Parameter prompt dialog edit field.  ValueLimit simply determines whether the ValueMin and ValueMax properties are active or not.  If ValueLimit is set to cFalse, the ValueMin and ValueMax properties will be ignored.

With string Parameters, ValueMin and ValueMax limit the length of the string that can be input.  With other types, ValueMin and ValueMax contain the actual minimum and maximum values that can be entered.

Note

•	Value limits, and the EditMask property are mutually exclusive.  If an EditMask is defined, value limits will be ignored.

•	Value limits do not apply to Boolean Parameters.


ValueLimit property - See also
Related

ValueMin

ValueMax

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ValueLimit property - Example
Example

This example sets a ValueLimit for two ParamFields, a string and a datetime parameter:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{String Parameter: Entry Limit of 1 to 3 characters long}

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.ParamFields[0].ValueLimit := cTrue;

Crpe1.ParamFields[0].ValueMin := '1';

Crpe1.ParamFields[0].ValueMax := '3';

{DateTime Parameter: Entry must be between min and max datetime}

Crpe1.ParamFields[1].ShowDialog := True;

Crpe1.ParamFields[1].ValueLimit := cTrue;

Crpe1.ParamFields[1].ValueMin := '1997,01,01 12:00:00';

Crpe1.ParamFields[1].ValueMax := '1998,01,01 12:00:00';

Crpe1.Output := toWindow;

Crpe1.Execute;


ValueMax property

See also	Example

Applies to

ParamFields

Declaration

property ValueMax: string;

Description

The ValueLimit, ValueMin, and ValueMax properties work together.  They provide a way of limiting the input in the Parameter prompt dialog edit field.  ValueLimit simply determines whether the ValueMin and ValueMax properties are active or not.  If ValueLimit is set to cFalse, the ValueMin and ValueMax properties will be ignored.

With string Parameters, ValueMin and ValueMax limit the length of the string that can be input.  With other types, ValueMin and ValueMax contain the actual minimum and maximum values that can be entered.

Note

•	Value limits, and the EditMask property are mutually exclusive.  If an EditMask is defined, value limits will be ignored.

•	Value limits do not apply to Boolean Parameters.


ValueMax property - See also
Related

ValueMin

ValueLimit

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ValueMax property - Example
Example

This example sets a ValueLimit for two ParamFields, a string and a datetime parameter:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{String Parameter: Entry Limit of 1 to 3 characters long}

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.ParamFields[0].ValueLimit := cTrue;

Crpe1.ParamFields[0].ValueMin := '1';

Crpe1.ParamFields[0].ValueMax := '3';

{DateTime Parameter: Entry must be between min and max datetime}

Crpe1.ParamFields[1].ShowDialog := True;

Crpe1.ParamFields[1].ValueLimit := cTrue;

Crpe1.ParamFields[1].ValueMin := '1997,01,01 12:00:00';

Crpe1.ParamFields[1].ValueMax := '1998,01,01 12:00:00';

Crpe1.Output := toWindow;

Crpe1.Execute;


ValueMin property

See also	Example

Applies to

ParamFields

Declaration

property ValueMin: string;

Description

The ValueLimit, ValueMin, and ValueMax properties work together.  They provide a way of limiting the input in the Parameter prompt dialog edit field.  ValueLimit simply determines whether the ValueMin and ValueMax properties are active or not.  If ValueLimit is set to cFalse, the ValueMin and ValueMax properties will be ignored.

With string Parameters, ValueMin and ValueMax limit the length of the string that can be input.  With other types, ValueMin and ValueMax contain the actual minimum and maximum values that can be entered.

Note

•	Value limits, and the EditMask property are mutually exclusive.  If an EditMask is defined, value limits will be ignored.

•	Value limits do not apply to Boolean Parameters.


ValueMin property - See also
Related

ValueMax

ValueLimit

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ValueMin property - Example
Example

This example sets a ValueLimit for two ParamFields, a string and a datetime parameter:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{String Parameter: Entry Limit of 1 to 3 characters long}

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.ParamFields[0].ValueLimit := cTrue;

Crpe1.ParamFields[0].ValueMin := '1';

Crpe1.ParamFields[0].ValueMax := '3';

{DateTime Parameter: Entry must be between min and max datetime}

Crpe1.ParamFields[1].ShowDialog := True;

Crpe1.ParamFields[1].ValueLimit := cTrue;

Crpe1.ParamFields[1].ValueMin := '1997,01,01 12:00:00';

Crpe1.ParamFields[1].ValueMax := '1998,01,01 12:00:00';

Crpe1.Output := toWindow;

Crpe1.Execute;


CopyFrom method

See also	Example

Applies to

ParamFields

Declaration

procedure CopyFrom(Source: TCrpeParamFields);

Description

The CopyFrom method copies the ParamFields property values from another TCrpeParamFields object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the ParamFields property values to a temporary TCrpeParamFields object:

var

tempParamFields : TCrpeParamFields;

begin

tempParamFields := TCrpeParamFields.Create;

tempParamFields.CopyFrom(Crpe1.ParamFields);

{...later, when finished with the temp object...}

tempParamFields.Free;

end;


IndexOf method

See also	Example

Applies to

ParamFields

Declaration

function IndexOf(ParameterName: TCrParamFieldName): integer;

Type

TCrParamFieldName = string[255];

Description

The IndexOf method takes a Parameter name and returns the index position of the Parameter item in the current ParamFields object.

After the Retrieve method has been called, the ParamFields object contains one item for each ParamField in the Report.  The IndexOf method can be used to determine if a given Parameter Name actually exists in the ParamFields object before trying to access it.


IndexOf method - See also
Related

Name

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

The following code illustrates the use of the IndexOf method to locate a specific ParamField item by it's name:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{Find "Param1"}

nItem := Crpe1.ParamFields.IndexOf('Param1');

{If it exists...}

if nItem > -1 then

begin

with Crpe1.ParamFields[nItem] do

begin

  Value := 'CA';

  ShowDialog := False;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


RetrieveValues method

See also	Example

Applies to

ParamFields

Declaration

function RetrieveValues: boolean;

Description

The RetrieveValues method was added to the ParamFields class with the 7.x.0.20 release of the VCL, in order to reduce the confusion that was being caused by having two methods of passing values to a ParamField: the Value property (for single values) and the CurrentValues/DefaultValues properties (for multiple values).

CurrentValues/DefaultValues are no longer automatically retrieved into the ParamFields object when the Retrieve method is called.  Instead, they must be retrieved separately for each ParamField item (in other words, after the main Retrieve method has been called).

After RetrieveValues has been called, the CurrentValues and DefaultValues properties will contain any Current or Default values that are stored in the Report that is loaded into memory.


RetrieveValues method - See also
Related

CurrentValues

DefaultValues

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


RetrieveValues method - Example
Example

The following code illustrates the use of the RetrieveValues method to obtain the CurrentValues and DefaultValues for a specific ParamField item:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].RetrieveValues;

ShowMessage(Crpe1.ParamFields[0].DefaultValues.Text);

ShowMessage(Crpe1.ParamFields[0].CurrentValues.Text);

end;


PickList property

See also	Example

Applies to

ParamFields

Declaration

property PickList: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

PickList is a StringList that contains multiple values that are to be passed to a Crystal Parameter Field.  PickList values will appear in the Crystal Parameter Field prompt dialog as descriptive items that either show instead of the DefaultValues specified, or show alongside with the DefaultValues.  Since the DefaultValues may not be descriptive enough for the end-user, the PickList strings can be used to add more descriptive language.  Naturally, PickList is only meaningful if you are using the Crystal Parameter Field prompt dialog to select the Parameter value, which requires that the ShowDialog property be set to True.

To clear the PickList values from simply clear the DefaultValues, since the VCL will only look for PickList values if there are DefaultValues specified.  To clear DefaultValues, the CrEmptyStr constant should be used.

{Clear the first Parameter's DefaultValues from the Report}

Crpe1.ParamFields[0].DefaultValues.Text := CrEmptyStr;

Important

PickList and its related properties require SCR7 (maintenance release version) or higher.

Note

To read and write PickList using native Delphi types (boolean, currency, datetime, etc.), use the following methods (in the UCrpeUtl unit):

Reading

CrStrToBoolean

CrStrToDate

CrStrToDateTime

CrStrToFloating

CrStrToTime

Writing

CrBooleanToStr

CrDateTimeToStr

CrDateToStr

CrFloatingToStr

CrTimeToStr

Extracting Parts

ExDateStr

ExDateTimeStr

ExTimeStr


PickList property - See also
Related

PLDescriptionOnly

PLSortMethod

PLSortByDescription

DefaultValues

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PickList property - Example
Example

This example adds 2 DefaultValues to the first ParamField, and then 2 PickList Values to stand in their place.  These PickList values will be offered as choices when the Parameter prompt dialog appears:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.ParamFields[0].DefaultValues.Add('ATK');

Crpe1.ParamFields[0].DefaultValues.Add('JNS');

Crpe1.ParamFields[0].PickList.Add('Atkinson');

Crpe1.ParamFields[0].PickList.Add('Jones');

Crpe1.Output := toWindow;

Crpe1.Execute;


PLDescriptionOnly property

See also	Example

Applies to

ParamFields

Declaration

property PLDescriptionOnly: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The PLDescriptionOnly property applies to PickList values.  If PLDescriptionOnly is set to cTrue, only the PickList strings will appear in the Parameter Field prompt dialog (the DefaultValues will be hidden).  If PLDescriptionOnly is set to cFalse, both DefaultValues and PickList values will appear in the Parameter Field prompt dialog.

Important

PickList and its related properties require SCR7 (maintenance release version) or higher.


PLDescriptionOnly property - See also
Related

PickList

PLSortMethod

PLSortByDescription

DefaultValues

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PLDescriptionOnly property - Example
Example

This example adds 2 DefaultValues to the first ParamField, and then 2 PickList Values to stand in their place.  These PickList values will be offered as choices when the Parameter prompt dialog appears.  Only the PickList values will be visible in the dialog, due to the setting of the PLDescriptionOnly property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.DiscardData;

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.ParamFields[0].DefaultValues.Add('ATK');

Crpe1.ParamFields[0].DefaultValues.Add('JNS');

Crpe1.ParamFields[0].PickList.Add('Atkinson');

Crpe1.ParamFields[0].PickList.Add('Jones');

Crpe1.ParamFields[0].PLDescriptionOnly := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


PLSortMethod property

See also	Example

Applies to

ParamFields

Declaration

property PLSortMethod: TCrPickListSortMethod;

Type

TCrPickListSortMethod = (psmNoSort, psmAlphaNumericAscending, psmAlphaNumericDescending, psmNumericAscending, psmNumericDescending, psmDefaultSort);

Description

The PLSortMethod property applies to PickList values.  PLSortMethod determines how the PickList values will sort when they appear in the Parameter Field prompt dialog.

•	If PLSortByDescription is set to cTrue, the sort method will apply to the PickList values only.

•	If PLSortByDescription is set to cFalse, the sort method will apply to the DefaultValues, whether they are visible or not (if PLDescriptionOnly is set to cTrue, only the PickList values will show, otherwise the DefaultValues will show also).

Important

PickList and its related properties require SCR7 (maintenance release version) or higher.


PLSortMethod property - See also
Related

PickList

PLDescriptionOnly

PLSortByDescription

DefaultValues

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PLSortMethod property - Example
Example

This example adds 2 DefaultValues to the first ParamField, and then 2 PickList Values to stand in their place.  These PickList values will be offered as choices when the Parameter prompt dialog appears.  Only the PickList values will be visible in the dialog, due to the setting of the PLDescriptionOnly property.  As well, the choices will be sorted Alpha Numeric descending:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.DiscardData;

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.ParamFields[0].DefaultValues.Add('ATK');

Crpe1.ParamFields[0].DefaultValues.Add('JNS');

Crpe1.ParamFields[0].PickList.Add('Atkinson');

Crpe1.ParamFields[0].PickList.Add('Jones');

Crpe1.ParamFields[0].PLDescriptionOnly := cTrue;

Crpe1.ParamFields[0].PLSortByDescription := cTrue;

Crpe1.ParamFields[0].PLSortMethod := psmAlphaNumericDescending;

Crpe1.Output := toWindow;

Crpe1.Execute;


PLSortByDescription property

See also	Example

Applies to

ParamFields

Declaration

property PLSortByDescription: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The PLSortByDescription property applies to PickList values.

•	If PLSortByDescription is set to cTrue, the drop-down list of values in the Parameter Field prompt dialog will appear sorted by the PickList strings.

•	If PLSortByDescription is set to cFalse, the sorting of the values will be determined by the PLSortMethod property or by the order of the DefaultValues.

Important

PickList and its related properties require SCR7 (maintenance release version) or higher.


PLSortByDescription property - See also
Related

PickList

PLDescriptionOnly

PLSortMethod

DefaultValues

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PLSortByDescription property - Example
Example

This example adds 2 DefaultValues to the first ParamField, and then 2 PickList Values to stand in their place.  These PickList values will be offered as choices when the Parameter prompt dialog appears.  Only the PickList values will be visible in the dialog, due to the setting of the PLDescriptionOnly property.  As well, the choices will be sorted Alpha Numeric descending, controlled by PLSortByDescription and PLSortMethod:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.DiscardData;

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.ParamFields[0].DefaultValues.Add('ATK');

Crpe1.ParamFields[0].DefaultValues.Add('JNS');

Crpe1.ParamFields[0].PickList.Add('Atkinson');

Crpe1.ParamFields[0].PickList.Add('Jones');

Crpe1.ParamFields[0].PLDescriptionOnly := cTrue;

Crpe1.ParamFields[0].PLSortByDescription := cTrue;

Crpe1.ParamFields[0].PLSortMethod := psmAlphaNumericDescending;

Crpe1.Output := toWindow;

Crpe1.Execute;


Params

See also	Properties & Methods	Example

Applies to

SQL

Declaration

property Params: TCrpeStoredProcParams;

Type

TCrpeStoredProcParams = class(TPersistent)

Description

Note: For SCR 7, Params are now handled through the ParamFields object.

The Params object is a member of the SQL object, and contains all the properties that relate to Stored Procedure Parameters.

•	The Name property specifies the name of the Parameter.

•	The Value property specifies the actual value to be passed into the Stored Procedure Parameter.  To set a parameter value for the Stored Procedure to NULL, pass the string constant 'CRWNull' to the Value property.

•	The ParamType property is a read-only property that contains the data type of the Parameter.

•	The Number property, or the default array property, Item, or the ItemIndex property can be used to navigate through the various Parameters stored in the Params object.

•	The Retrieve method can be used to get the Params from a Report.

•	The Count method will indicate how many Parameters are in the Params object.

All Parameter values are stored as string values.  To pass a numeric value to the Value property directly, pass the value in quotes like this: '100'.  The Crystal Reports Print Engine will treat this as the value 100.  To pass other types, either convert them to a string representation, or use one of the properties that can read and write to the Value property using native Delphi types:

AsInteger

AsFloat

AsBoolean

AsDate

Note

When passing Boolean parameters, better results will be achieved by using '1' or '0' instead of 'True' or 'False'.  The AsBoolean property already does this, so it is only necessary to keep in mind if you are writing directly to the Value property.


Params - See also
Related

SQL

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Params - Properties & Methods
Params:

Properties & Methods

Params	TCrpe Component

Properties

Value

Key

Name

Parameter Information

ParamType

Conversion

AsBoolean

AsDate

AsDateTime

AsFloat

AsInteger

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


Params - Example
Example

In the code following, the Stored Procedure Parameters are first retrieved, then the first and second Params are passed new values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

Crpe1.SQL.Params[0].Value := '100';

Crpe1.SQL.Params[1].Value := '200';

Crpe1.Execute;


Item property

See also	Example

Applies to

Params

Declaration

property Item[const nIndex: integer]: TCrpeStoredProcParams;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the Params object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  Params[2] is the same as Params.Item[2].

•	Item returns a reference to the Params object, so the Params properties can be used right after the subscript: Params[2].Value := '100';


Item property - See also
Related

ItemIndex

Name

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

{Set Params object to the 3rd parameter}

Crpe1.SQL.Params.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

{Set Params object to the 3rd parameter}

Crpe1.SQL.Params[2];


ItemIndex property

See also	Example

Applies to

Params

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current Params item number, or set the Params object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (Params[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the Params object is pointing to the first Params item:

if Crpe1.SQL.Params.ItemIndex <> 0 then

  Crpe1.SQL.Params[0];


Name property

See also	Example

Applies to

Params

Declaration

property Name: TCrStoredProcParamName;

Type

TCrStoredProcParamName = string[128];

Description

The Name property is the key, or lookup property for the Params object.  As such, it cannot be directly overwritten with a new value.  Instead, setting a new value to the Name property will cause it to navigate the Params object to the matching item, or generate an error if the name does not exist.  Before using the Name property to navigate through the Params, the Retrieve method should be called, or the manual Add method.


Name property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Name property - Example
Example

This example illustrates the use of the Name property to navigate through the Params object:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

{Set Params object to item 'FirstParam' name}

Crpe1.SQL.Params.Name := 'FirstParam';

{Set Params item Value}

Crpe1.SQL.Params.Value := 'CA';

Crpe1.Output := toWindow;

Crpe1.Execute;

Note that since there is an internal index in the Params object (and most of the other Crystal VCL sub-class objects), it is not necessary to specify a subscript (ie. Params[0].Value) every time a property is set.  Once the sub-class object is pointing to a certain item, the other properties apply to that item, whether the subscript is specified or not.


ParamType property

See also	Example

Applies to

Params

Declaration

property ParamType: TCrStoredProcParamType;

Type

TCrStoredProcParamType = (spLongVarChar, spBinary, spVarBinary, spLongVarBinary, spBigInt, spTinyInt, spBit, spChar, spNumeric, spDecimal, spInteger, spSmallInt, spFloat, spReal, spDouble, spDate, spTime, spTimeStamp, spVarChar);

Description

ParamType is a read-only property that will only have a meaningful value if the Retrieve method is used to obtain Params items from the Report.  It indicates what data type the Value property is expecting.

Note

It is not possible to change the type of a Params item at runtime.  This must be done within the Crystal Reports designer.


ParamType property - See also
Related

Value

AsBoolean

AsCurrency

AsDate

AsNumber

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ParamType property - Example
Example

The ParamType property can be used to check the type of Value the Params item expects:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

for cnt := 0 to (Crpe1.SQL.Params.Count - 1) do

begin

  case Crpe1.SQL.Params[cnt].ParamType of

    spLongVarChar   : Crpe1.SQL.Params[cnt].Value := 'CA';

    spBinary        : Crpe1.SQL.Params[cnt].Value := '0';  {?}

    spVarBinary     : Crpe1.SQL.Params[cnt].Value := '10'; {?}

    spLongVarBinary : Crpe1.SQL.Params[cnt].Value := '10'; {?}

    spBigInt        : Crpe1.SQL.Params[cnt].AsInteger := 1;

    spTinyInt       : Crpe1.SQL.Params[cnt].AsInteger := 1;

    spBit           : Crpe1.SQL.Params[cnt].AsNumber := 1; {?}

    spChar          : Crpe1.SQL.Params[cnt].Value := 'CA';

    spNumeric       : Crpe1.SQL.Params[cnt].AsInteger := 1;

    spDecimal       : Crpe1.SQL.Params[cnt].AsFloat := 1.23;

    spInteger       : Crpe1.SQL.Params[cnt].AsInteger := 1;

    spSmallInt      : Crpe1.SQL.Params[cnt].AsInteger := 1;

    spFloat         : Crpe1.SQL.Params[cnt].AsFloat := 1.23;

    spReal          : Crpe1.SQL.Params[cnt].AsFloat := 1.23;

    spDouble        : Crpe1.SQL.Params[cnt].AsFloat := 1.23;

    spDate          : Crpe1.SQL.Params[cnt].AsDate := Now;

    spTime          : Crpe1.SQL.Params[cnt].Value := '12:00:00.000';

    spTimeStamp     : Crpe1.SQL.Params[cnt].AsDate := Now;

    spVarChar       : Crpe1.SQL.Params[cnt].Value := 'CA';

  end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


Value property

See also	Example

Applies to

Params

Declaration

property Value: string;

Description

The Value property contains the actual value of the Stored Procedure Parameter.  If the Retrieve method was called, the Value property will show the current value of the parameter(s) as stored in the Report.

All parameter values are stored as string values.  If you wish to pass other types, they will either need to be converted to a string representation, or you will need to use one of the four other properties that can be used to read and write to the Text property using native Delphi types:  AsInteger, AsFloat, AsBoolean, AsDate.

To pass a number to the Value property directly, pass the value in quotes like this: '100'. The Crystal Reports Print Engine will treat this as the value 100.  To pass it via the AsInteger property do this:  Params.AsInteger := 100.

If you want to set the parameter value for the Stored Procedure to NULL, pass the string constant 'CRWNull' to the Value property.


Value property - See also
Related

AsBoolean

AsDate

AsFloat

AsInteger

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Value property - Example
Example

The Value property is used to pass new values to a Stored Procedure Parameter:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

for cnt := 0 to (Crpe1.SQL.Params.Count - 1) do

  Crpe1.SQL.Params[cnt].Value := 'CA';

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

Params

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Params object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

Params

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

Params

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the Params object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SQL.Params.Retrieve;

  for cnt := 0 to (Crpe1.SQL.Params.Count - 1) do

    Crpe1.SQL.Params[cnt].Value := 'CA';

end;


Retrieve method

See also	Example

Applies to

Params

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Stored Procedure Parameter information from the Report and adds one item to the Params object for each Stored Procedure Parameter in the Report.  If Stored Procedure Parameters were not found, the call returns False.  Be aware that calling Retrieve will first cause the Params object to be cleared, so any current information stored in it will be removed.

Note

Since the Params object also applies to Subreports, the Retrieve method will obtain the Params for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the Params information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate Params information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.SQL.Params.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

Params

Declaration

function Send: boolean;

Description

The Send method sends the Params values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the Params settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SQL.Params.Send;


Add method

See also	Example

Applies to

Params

Declaration

function Add(ParamName: TCrStoredProcParamName): integer;

Type

TCrStoredProcParamName = string[128];

Description

The Add method adds an item to the Params object and sets the internal index to that item.  It requires a Stored Procedure Parameter name as a parameter, which should be a name corresponding to a Stored Procedure Parameter in the Report.  If the Add method is used, the steps to using Params are:

1. Add an item to the Params object (you must specify the Parameter name).

2. Fill the Value property.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Parameter names are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the Params object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Parameter Name - must be same as in Report}

Crpe1.SQL.Params.Add('Parameter1');

Crpe1.SQL.Params.Value := 'CA';

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

Params

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the Params object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the Params object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the Params of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the Params properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.SQL.Params.Clear;

This code clears the Params properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.SQL.Params.Clear;

end;


Delete method

See also	Example

Applies to

Params

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the Params object.  The "nIndex" parameter represents the number of the item in the Params object.

Note

Delete will not remove the Stored Procedure Parameters from the Report, it will just remove it from the Crystal VCL.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the Params object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Parameter Name - must be same as in Report}

Crpe1.SQL.Params.Add('Parameter1');

Crpe1.SQL.Params.Value := 'CA';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SQL.Params.Delete(0);


AsInteger property

See also	Example

Applies to

Params

Declaration

property AsInteger: integer;

Description

The AsInteger property can be used to read and write to the Value property using native Delphi integer values instead of the string values normally required by Value.


AsInteger property - See also
Related

Value

AsBoolean

AsDate

AsDateTime

AsFloat

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsInteger property - Example
Example

This example uses the AsInteger property to pass in a native Delphi integer value as the first parameter value to the Stored Procedure the Report is based on:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

Crpe1.SQL.Params[0].AsInteger := 1;

Crpe1.Execute;


AsFloat property

See also	Example

Applies to

Params

Declaration

property AsFloat: double;

Description

The AsFloat property can be used to read and write to the Value property using native Delphi floating point values instead of the string values normally required by Value.


AsFloat property - See also
Related

Value

AsBoolean

AsDate

AsDateTime

AsInteger

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsFloat property - Example
Example

This example uses the AsFloat property to pass in a native Delphi floating point value as the first parameter value to the Stored Procedure the Report is based on:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

Crpe1.SQL.Params[0].AsFloat := 1.22;

Crpe1.Execute;


AsBoolean property

See also	Example

Applies to

Params

Declaration

property AsBoolean: boolean;

Description

The AsBoolean property can be used to read and write to the Value property using native Delphi boolean values instead of the string values normally required by Value.


AsBoolean property - See also
Related

Value

AsDate

AsDateTime

AsFloat

AsInteger

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsBoolean property - Example
Example

This example uses the AsBoolean property to pass in a native Delphi boolean value as the first parameter value to the Stored Procedure the Report is based on:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

Crpe1.SQL.Params[0].AsBoolean := True;

Crpe1.Execute;


AsDate property

See also	Example

Applies to

Params

Declaration

property AsDate: TDateTime;

Description

The AsDate property can be used to read and write to the Value property using native Delphi DateTime values instead of the string values normally required by Value.

•	When reading this property, only the Date part of the Value string will be included in the result returned.

•	When writing this property, only the Date part of the TDateTime passed to it will be formatted in the Value string.

Note

Most Stored Procedure Parameters that involve dates are read by the Print Engine as a formatted date/time string:  '1997-01-01 00:00:00.000'.  When sending the Param values back to the Engine, if the time part is not included, even though it may not be used by the Stored Procedure, an error will result.  When in doubt, inspect the format of the Value property after calling the Retrieve method, and the expected format will be displayed.  If it includes the time, use the AsDateTime property instead of AsDate.


AsDate property - See also
Related

Value

AsBoolean

AsDateTime

AsFloat

AsInteger

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsDate property - Example
Example

This example uses the AsDate property to pass in a native Delphi datetime value as the first parameter value to the Stored Procedure the Report is based on:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

Crpe1.SQL.Params[0].AsDate := Now;

Crpe1.Execute;


AsDateTime property

See also	Example

Applies to

Params

Declaration

property AsDateTime: TDateTime;

Description

The AsDateTime property can be used to read and write to the Value property using native Delphi datetime values instead of the string values normally required by Value.

•	When reading this property, both the Date and Time portions of the Value string will be included in the result returned.

•	When writing this property, both the Date and Time portions of the TDateTime passed in will be formatted in the Value string.


AsDateTime property - See also
Related

Value

AsBoolean

AsDate

AsFloat

AsInteger

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AsDateTime property - Example
Example

This example uses the AsDateTime property to pass in a native Delphi datetime value as the first parameter value to the Stored Procedure the Report is based on:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Params.Retrieve;

Crpe1.SQL.Params[0].AsDateTime := Now;

Crpe1.Execute;


CopyFrom method

See also	Example

Applies to

Params

Declaration

procedure CopyFrom(Source: TCrpeStoredProcParams);

Description

The CopyFrom method copies the Params property values from another TCrpeStoredProcParams object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Params property values to a temporary TCrpeStoredProcParams object:

var

tempParams : TCrpeStoredProcParams;

begin

tempParams := TCrpeStoredProcParams.Create;

tempParams.CopyFrom(Crpe1.SQL.Params);

{...later, when finished with the temp object...}

tempParams.Free;

end;


SQL

See also	Properties & Methods	Example

Declaration

property SQL: TCrpeSQL;

Type

TCrpeSQL = class(TPersistent)

Description

The SQL object is only applicable to a Report created from an ODBC Data Source or from a native SQL database connection and contains the SQL Query property, the Expressions object, and the Params object, which pertains to Stored Procedure Parameters in Crystal 6 and lower (Crystal 7 uses the ParamFields object for Stored Procedure Parameters).

•	The Query property contains the text of an SQL Query.  The Query property can be used to update the SQL Query that will be used to print the Report, typically to add optimizations to the WHERE clause.  This property is particularly useful for reports with SQL Queries that were explicitly edited in the Show SQL Query dialog box in Crystal Reports (i.e., those reports that needed database-specific selection criteria or joins).  Otherwise it is usually best to continue using other properties such as Selection and let Crystal Reports build the SQL Query automatically.

•	The Retrieve method can be used to retrieve the SQL Query from a Report and fill the Query property.  Note that before using Retrieve, the necessary LogOn information should be set via the Connect or LogOnInfo properties, otherwise the Query may be empty.

The SQL Query has the same restrictions as editing in the Show SQL Query dialog box in Crystal Reports. In particular, changes are accepted in the FROM, WHERE, and ORDER BY clauses but they are ignored in the SELECT part of the Query.  The reason for this is that the SELECT is determined by the database fields that are placed on the Report, and there is no way to remove or place new fields at runtime.


SQL - See also
Related

Params

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SQL - Properties & Methods
SQL:

Properties & Methods

SQL	TCrpe Component

Properties

Query

Stored Procedure Parameters

Params

SQL Expressions

Expressions

Methods

Clear

CopyFrom

Retrieve

Send

Constructor

Create

Destructor

Destroy


SQL - Example
Example

Crpe1.ReportName := 'C:\Company.rpt';

{Set the Connect before attempting to retrieve the Query}

Crpe1.Connect.Retrieve;

Crpe1.Connect.Password := 'Aesop';

{Retrieve the Query}

Crpe1.SQL.Retrieve;

{Edit the WHERE clause, assuming in this case that it is line 5}

Crpe1.SQL.Query[4] := 'WHERE DEPT."LOC" = '''BOSTON'''';

Crpe1.Execute;


Params - see 2700


Expressions - see 5900


Query property

See also	Example

Applies to

SQL

Declaration

property Query: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The Query property is used to retrieve and send the SQL Query statement used by a specified Report.  This will only be available if the Report is based off SQL databases, or ODBC Data Sources.  Query does not apply to PC-type databases (dBase, FoxPro, Access, Paradox, etc.) using native drivers.

The SELECT part of the Query cannot be changed, since it is determined by the fields that are placed in the Report.  Although the property requires that the entire SQL Query statement be entered, the SELECT section must not be different from the original Query.  If an ORDER BY clause will be included, it must be preceded with CHR(13) and CHR(10) (carriage return/line feed).

Note

Crystal Reports will attempt to translate any Selection formula and SortFields sort order into the WHERE and ORDER BY parts of the SQL Query when the Report is run.  For this reason, it may be easier to pass values into these properties instead of modifying the SQL Query directly.  Conversely, modifying the SQL Query will cause the Selection formula in a Report to be removed when the Report is run.


Query property - See also
Related

Selection

SortFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Query property - Example
Example

The following example uses the Query property to pass a new SQL statement to the Report:

Crpe1.ReportName := 'C:\Company.rpt';

{Set the LogOn}

Crpe1.Connect.Retrieve;

Crpe1.Password := 'Aesop';

{Set the SQL Query}

Crpe1.SQL.Query[0] := 'SELECT DEPT."DEPTNO", DEPT."DNAME", DEPT."LOC"';

Crpe1.SQL.Query[1] := 'FROM "SCOTT"."DEPT" DEPT';

Crpe1.SQL.Query[2] := 'WHERE DEPT."DEPTNO" = 10';

Crpe1.SQL.Query[3] := 'ORDER BY DEPT."DNAME" ASC';

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

SQL

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the SQL object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

SQL

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method

See also	Example

Applies to

SQL

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SQL Query information from the Report and stores it in the SQL.Query property of the component.  If an SQL Query was not found, or a connection could not be made to the SQL Server (which is required to retrieve the Query), the call returns False.  Be aware that calling Retrieve will first cause the SQL Query property in the VCL to be cleared, so any current information stored in it will be removed.

Note

Since the SQL object also applies to Subreports, the Retrieve method will obtain the SQL.Query for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the SQL.Query information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate SQL.Query information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.SQL.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

SQL

Declaration

function Send: boolean;

Description

The Send method sends the SQL values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the SQL settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SQL.Send;


Clear method

See also	Example

Applies to

SQL

Declaration

procedure Clear;

Description

This method can be used to clear the Query property of the SQL object.  It is the same as:

Crpe1.SQL.Query.Clear;

It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the SQL Query of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the SQL Query of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the SQL Query for the main Report (assuming the default state of Subreports[0]):

Crpe1.SQL.Clear;

This code clears the SQL Query for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.SQL.Clear;

end;


CopyFrom method

See also	Example

Applies to

SQL

Declaration

procedure CopyFrom(Source: TCrpeSQL);

Description

The CopyFrom method copies the SQL property values from another TCrpeSQL object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.

Note

At this time, the CopyFrom for SQL only copies the Query.  If you want to copy Params, or Expressions, you will have to copy them separately.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the SQL property values to a temporary TCrpeSQL object:

var

tempSQL : TCrpeSQL;

begin

tempSQL := TCrpeSQL.Create;

tempSQL.CopyFrom(Crpe1.SQL);

{...later, when finished with the temp object...}

tempSQL.Free;

end;


Selection

See also	Properties & Methods	Example

Declaration

property Selection: TCrpeSelectionFormula;

Type

TCrpeSelectionFormula = class(TPersistent)

Description

The Selection object deals with the Selection Formula of a Report.  It's main properties and methods are:

•	The Formula property is used to hold the text of the Selection Formula

•	The Replace property is a boolean property that specifies if the text in the Formula property will replace the Selection that is already in the Report, or whether it will be ANDed on to the end of it.

•	The Retrieve method will fetch the Selection Formula that is currently in the Report, and place it in the Formula property.

•	The Check method can be used to determine whether the Formula syntax is correct.


Selection - See also
Related

Formulas

GroupSelection

ParamFields

Using Variables with Selection Formula

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Selection - Properties & Methods
Selection:

Properties & Methods

Selection	TCrpe Component

Properties

Formula

Replace

Methods

Check

Clear

CopyFrom

Retrieve

Send

Constructor

Create

Destructor

Destroy


Selection - Example
Example

This code sample passes a new Selection formula into the Report, replacing the one that was currently there:

Crpe1.ReportName := 'Report1.rpt';

Crpe1.Selection.Formula.Clear;

Crpe1.Selection.Formula.Add('{company.STATE} = "CA"');

{or Crpe1.Selection.Formula.Text := '{company.STATE} = "CA"';}

Crpe1.Selection.Replace := True;

Crpe1.Execute;

Since one line in the Crystal Reports Formula Editor is limited to 255 characters, Selections built with a large number of items must be split onto more than one line.  The code below handles this type of case.  Items are read from a ListBox, and after every 4, a new line is added to the Selection Formula:

procedure RunReport;

var

  cnt1,cnt2 : integer;

  sTmp      : string;

begin

  Crpe1.ReportName := 'D:\Company.rpt';

  Crpe1.Selection.Formula.Clear;

  {This Memo shows the syntax of the final Formula}

  Memo1.Clear;

  cnt1 := 0;

  cnt2 := 0;

  {If the ListBox contains items to add to the Selection}

  if ListBox1.Items.Count > 0 then

  begin

    {Store the beginning of the Selection}

    sTmp := '{company.CONAME} in [';

    {Loop through the ListBox items}

    while cnt1 < ListBox1.Items.Count do

    begin

      {Take 4 items per SelectionFormula line}

      while cnt2 < 4 do

      begin

        {If it's the last item, add a close bracket}

        if cnt1 = (ListBox1.Items.Count - 1) then

        begin

          sTmp := sTmp + '"' + Listbox1.Items[cnt1] + '"]';

          cnt2 := 3;

        end

        {If it's not the last item, add a comma}

        else

          sTmp := sTmp + '"' + Listbox1.Items[cnt1] + '"' + ',';

        {Increment the counters}

        Inc(cnt2);

        Inc(cnt1)

      end;

      {Reset the item counter}

      cnt2 := 0;

      {Add the line to the Selection}

      Crpe1.Selection.Formula.Add(sTmp);

      sTmp := '';

    end;

  end;

  {Write the Formula to a Memo so we can view it}

  Memo1.Lines.AddStrings(Crpe1.SelectionFormula);

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Formula property

See also	Example

Applies to

Selection

Declaration

property Formula: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The Formula property specifies the actual Selection Formula text.  Any values in the selection formula that must be seen as strings should be put in double quotes, for example:

Crpe1.Selection.Formula.Text := '{company.STATE} = "CA"';

When the Replace property is set to False, the Selection Formula that is passed in to the Report is appended with a Boolean  "AND"  to any characters in the Selection Formula currently in the Report.  This includes comment lines (any text on a line with two forward slashes in front of it)  and existing Selection Formulas.  Therefore, care must be taken to make sure the Selection Formula in the Report is valid.  When in doubt, use the Retrieve method and build the whole statement in Delphi, then replace the current Selection, by setting Replace to True.

•	To clear the Selection in a Report, so that it is blank, use the CrEmptyStr constant:

{When the Report is run, the Selection will be cleared in the Report}

Crpe1.Selection.Formula.Text := CrEmptyStr;

See also Using Variables with Selection Formula.


Formula property - See also
Related

Using Variables with Selection Formula

Replace

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Formula property - Example
Example

The following example retrieves the current Selection Formula from the Report and adds an OR condition:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Selection}

Crpe1.Selection.Retrieve;

{Add an OR condition}

Crpe1.Selection.Formula.Add(' OR {company.STATE} = "WA"');

{Replace the Selection in the Report with the new one}

Crpe1.Selection.Replace := True;

{Check the Selection before running Report}

if Crpe1.Selection.Check then

begin

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Replace property

See also	Example

Applies to

Selection

Declaration

property Replace: boolean;

Description

The Replace property determines if the Selection Formula sent from the VCL will replace the one that is already in the Report (if there is one), or if it will be ANDed on to the end.  For example, if there is a Selection Formula in the Report that reads:

{company.STATE} = "WA"

And there is a Selection Formula in the VCL that reads:

{company.SALES} = 100000

If Replace is True, the Selection Formula in the Report (when it is run) will read:

{company.SALES} = 100000

If Replace is False, the Selection Formula in the Report (when it is run) will read:

{company.STATE} = "WA" AND {company.SALES} = 100000

By default, Replace is set to True.


Replace property - See also
Related

Formula

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Replace property - Example
Example

The following example retrieves the current Selection Formula from the Report and adds an OR condition.  It then sends the Formula back in, replacing the one that is currently there:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Selection}

Crpe1.Selection.Retrieve;

{Add an OR condition}

Crpe1.Selection.Formula.Add(' OR {company.STATE} = "WA"');

{Replace the Selection in the Report with the new one}

Crpe1.Selection.Replace := True;

{Check the Selection before running Report}

if Crpe1.Selection.Check then

begin

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Create method

See also

Applies to

Selection

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Selection object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

Selection

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Check method

See also	Example

Applies to

Selection

Declaration

function Check: boolean;

Description

The Check method can be used to check the syntax of a Selection Formula before running the Report.  Check returns a boolean value:

True	: Selection Formula is good.

False	: Selection Formula has an error.


Check method - See also
Related

Formula

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Check method - Example
Example

The following example retrieves the current Selection Formula from the Report and adds an OR condition.  It then sends the Formula back in, checking it for proper syntax:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Selection}

Crpe1.Selection.Retrieve;

{Add an OR condition}

Crpe1.Selection.Formula.Add(' OR {company.STATE} = "WA"');

{Replace the Selection in the Report with the new one}

Crpe1.Selection.Replace := True;

{Check the Selection before running Report}

if Crpe1.Selection.Check then

begin

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Retrieve method

See also	Example

Applies to

Selection

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Selection Formula from the Report and stores it in the Formula property of the Selection object.  If successful, the call returns True.  Be aware that calling Retrieve will first cause the Selection object to be cleared, so any current information stored in it will be removed.

Note

Since the Selection object also applies to Subreports, the Retrieve method will obtain the Selection for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the Selection information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate Selection information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Selection.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.Selection.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

Selection

Declaration

function Send: boolean;

Description

The Send method sends the Selection values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the Selection settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.Selection.Send;


Clear method

See also	Example

Applies to

Selection

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the Selection object.  It clears the Formula property and sets the Replace property to True.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the Selection object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the Selection of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the Selection for the main Report (assuming the default state of Subreports[0]):

Crpe1.Selection.Clear;

This code clears the Selection for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.Selection.Clear;

end;


Using Variables with Selection Formula

Delphi variables can be used with the Selection Formula if they are declared as string or converted to string (regardless of the actual data type) before being passed to Crystal Reports.  Remember also, that string values require extra quotes for Crystal Reports, as well as the usual single quotes that Delphi requires.  The following examples cover some of the ways in which variables can be used:

1. Passing a String variable with extra quotes included:

var

  sTmp : string

begin

  sTmp := '"CA"';

  Crpe1.Selection.Formula[0] := '{company.STATE} = ' + sTmp;

2. Passing a String variable without extra quotes included:

var

  sTmp : string;

begin

  sTmp := 'CA';

  Crpe1.Selection.Formula[0] := '{company.STATE} = "' + sTmp + '"';

3. Passing a String variable from an Edit box without extra quotes included:

var

  sTmp : string;

begin

  sTmp := Edit1.Text;

  Crpe1.Selection.Formula[0] := '{company.STATE} = "' + sTmp + '"';

4. Passing Integer values from Edit boxes:

var

  nStart : string;

  nEnd   : string;

begin

  nStart := Edit1.Text;

  nEnd := Edit2.Text;

  Crpe1.Selection.Formula[0] := '{company.SALES} >= ' + nStart + 'AND {company.SALES} <= ' + nEnd;

5. Passing Integer variables:

var

  nSales : integer;

begin

  nSales := 12345;

  Crpe1.Selection.Formula[0] := '{company.SALES} > ' + IntToStr(nSales);

5. Passing Date variables (Crystal Reports accepts dates only as a string data type in the Date(YYYY,MM,DD) format):

var

  dStart : string;

  dEnd   : string;

begin

  dStart := '1998,01,31';

  dEnd := '1998,06,30';

  Crpe1.Selection.Formula[0] := '{company.STARTDATE} in Date(' + dStart + ') to Date(' + dEnd + ')';

6. Passing Date variables divided into Day, Month, Year:

var

  dYear  : string;

  dMonth : string;

  dDay   : string;

begin

  dYear := '1998';

  dMonth := '06';

  dDay := '31';

  Crpe1.Selection.Formula[0] := '{company.STARTDATE} = Date(' + dYear + ',' + dMonth + ',' + dDay + ')';

6. Passing Date variables entered in Edit boxes:

var

  dYear  : string;

  dMonth : string;

  dDay   : string;

  dWhole : string;

begin

  dYear := Edit1.Text;

  dMonth := Edit2.Text;

  dDay := Edit3.Text;

  dWhole := 'Date(' + dYear + ',' + dMonth + ',' + dDay + ')';

  Crpe1.Selection.Formula[0] := '{company.STARTDATE} = ' + dWhole;


CopyFrom method

See also	Example

Applies to

Selection

Declaration

procedure CopyFrom(Source: TCrpeSelectionFormula);

Description

The CopyFrom method copies the Selection property values from another TCrpeSelectionFormula object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Selection property values to a temporary TCrpeSelectionFormula object:

var

tempSelection : TCrpeSelectionFormula;

begin

tempSelection := TCrpeSelectionFormula.Create;

tempSelection.CopyFrom(Crpe1.Selection);

{...later, when finished with the temp object...}

tempSelection.Free;

end;


GroupSelection

See also	Properties & Methods	Example

Declaration

property GroupSelection: TCrpeGroupSelectionFormula;

Type

TCrpeGroupSelectionFormula = class(TPersistent)

Description

The GroupSelection object deals with the Group Selection Formula of a Report.  It's main properties and methods are:

•	The Formula property holds the text of the Group Selection Formula.

•	The Replace property is a boolean property that specifies if the text in the Formula property will replace the Group Selection that is already in the Report, or whether it will be ANDed on to the end of it.

•	The Retrieve method will fetch the Group Selection Formula that is currently in the Report, and place it in the Formula property.

•	The Check method can be used to determine whether the Formula syntax is correct.


GroupSelection - See also
Related

Selection

Formulas

ParamFields

Using Variables with GroupSelection Formula

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupSelection - Properties & Methods
GroupSelection:

Properties & Methods

GroupSelection	TCrpe Component

Properties

Formula

Replace

Methods

Check

Clear

CopyFrom

Retrieve

Send

Constructor

Create

Destructor

Destroy


GroupSelection - Example
Example

This code sample passes a new Group Selection formula into the Report, replacing the one that was currently there:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSelection.Formula.Clear;

Crpe1.GroupSelection.Formula.Add('Sum({company.SALES}, {company.STATE}) > 30000.00');

{or Crpe1.GroupSelection.Formula.Text := }

Crpe1.GroupSelection.Replace := True;

Crpe1.Execute;


Formula property

See also	Example

Applies to

GroupSelection

Declaration

property Formula: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The Formula property specifies the actual GroupSelection Formula text.

When the Replace property is set to False, the GroupSelection Formula that is passed in to the Report is appended with a Boolean  "AND"  to any characters in the GroupSelection Formula currently in the Report.  This includes comment lines (any text on a line with two forward slashes in front of it)  and existing GroupSelection Formulas.  Therefore, care must be taken to make sure the GroupSelection Formula in the Report is valid.  When in doubt, use the Retrieve method and build the whole statement in Delphi, then replace the current GroupSelection, by setting Replace to True.

•	To clear the GroupSelection in a Report, so that it is blank, use the CrEmptyStr constant:

{When the Report is run, the GroupSelection will be cleared in the Report}

Crpe1.GroupSelection.Formula.Text := CrEmptyStr;

See also Using Variables with GroupSelection Formula.


Formula property - See also
Related

Using Variables with GroupSelection Formula

Replace

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Formula property - Example
Example

The following example retrieves the current Group Selection Formula from the Report and adds an OR condition:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the GroupSelection}

Crpe1.GroupSelection.Retrieve;

{Add an OR condition}

Crpe1.GroupSelection.Formula.Add(' OR Maximum({company.BRANCHES},{company.STATE}) > 12');

{Replace the GroupSelection in the Report with the new one}

Crpe1.GroupSelection.Replace := True;

{Check the GroupSelection before running Report}

if Crpe1.GroupSelection.Check then

begin

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Replace property

See also	Example

Applies to

GroupSelection

Declaration

property Replace: boolean;

Description

The Replace property determines if the Group Selection Formula sent from the VCL will replace the one that is already in the Report (if there is one), or if it will be ANDed on to the end.  For example, if there is a Selection Formula in the Report that reads:

{company.STATE} = "WA"

And there is a Selection Formula in the VCL that reads:

{company.SALES} = 100000

If Replace is True, the Selection Formula in the Report (when it is run) will read:

{company.SALES} = 100000

If Replace is False, the Selection Formula in the Report (when it is run) will read:

{company.STATE} = "WA" AND {company.SALES} = 100000

By default, Replace is set to True.


Replace property - See also
Related

Formula

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Replace property - Example
Example

The following example retrieves the current Group Selection Formula from the Report and adds an OR condition.  It then sends the Formula back in, replacing the one that is currently there:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the GroupSelection}

Crpe1.GroupSelection.Retrieve;

{Add an OR condition}

Crpe1.GroupSelection.Formula.Add(' OR Maximum({company.BRANCHES},{company.STATE}) > 12');

{Replace the GroupSelection in the Report with the new one}

Crpe1.GroupSelection.Replace := True;

{Check the GroupSelection before running Report}

if Crpe1.GroupSelection.Check then

begin

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Create method

See also

Applies to

GroupSelection

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the GroupSelection object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

GroupSelection

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Check method

See also	Example

Applies to

GroupSelection

Declaration

function Check: boolean;

Description

The Check method can be used to check the syntax of a GroupSelection Formula before running the Report.  Check returns a boolean value:

True	: GroupSelection Formula is good.

False	: GroupSelection Formula has an error.


Check method - See also
Related

Formula

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Check method - Example
Example

The following example retrieves the current Group Selection Formula from the Report and adds an OR condition.  It then sends the Formula back in, checking for the proper syntax:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the GroupSelection}

Crpe1.GroupSelection.Retrieve;

{Add an OR condition}

Crpe1.GroupSelection.Formula.Add(' OR Maximum({company.BRANCHES},{company.STATE}) > 12');

{Replace the GroupSelection in the Report with the new one}

Crpe1.GroupSelection.Replace := True;

{Check the GroupSelection before running Report}

if Crpe1.GroupSelection.Check then

begin

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Retrieve method

See also	Example

Applies to

GroupSelection

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Group Selection Formula from the Report and stores it in the Formula property of the GroupSelection object.  If successful, the call returns True.  Be aware that calling Retrieve will first cause the GroupSelection object to be cleared, so any current information stored in it will be removed and the Replace property will be set back to default.

Note

Since the GroupSelection object also applies to Subreports, the Retrieve method will obtain the GroupSelection for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the GroupSelection information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate GroupSelection information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSelection.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.GroupSelection.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

GroupSelection

Declaration

function Send: boolean;

Description

The Send method sends the GroupSelection values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the GroupSelection settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.GroupSelection.Send;


Clear method

See also	Example

Applies to

GroupSelection

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GroupSelection object.  It clears the Formula property and sets the Replace property to True.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the GroupSelection object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the GroupSelection of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the GroupSelection for the main Report (assuming the default state of Subreports[0]):

Crpe1.GroupSelection.Clear;

This code clears the GroupSelection for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.GroupSelection.Clear;

end;


Using Variables with GroupSelection Formula

Delphi variables can be used with the GroupSelection Formula if they are declared as string or converted to string (regardless of the actual data type) before being passed to Crystal Reports.  Remember also, that string values require extra quotes for Crystal Reports, as well as the usual single quotes that Delphi requires.  The following examples cover some of the ways in which variables can be used:

1. Passing Integer values from Edit boxes:

var

  nStart : string;

  nEnd   : string;

begin

  nStart := Edit1.Text;

  nEnd := Edit2.Text;

Crpe1.GroupSelection.Formula[0] :=

'Maximum({company.SALES},{company.STATE}) >= ' + nStart +

'AND Maximum({company.SALES},{company.STATE}) <= ' + nEnd;

2. Passing Integer variables:

var

  nSales : integer;

begin

  nSales := 12345;

  Crpe1.GroupSelection.Formula[0] := 'Maximum({company.SALES},{company.STATE}) > ' + IntToStr(nSales);

3. Passing Date variables (Crystal Reports accepts dates only as a string data type in the Date(YYYY,MM,DD) format):

var

  dStart : string;

  dEnd   : string;

begin

  dStart := '1998,01,31';

  dEnd := '1998,06,30';

  Crpe1.GroupSelection.Formula[0] := 'Maximum({company.STARTDATE},{company.STATE}) in Date(' + dStart + ') to Date(' + dEnd + ')';

4. Passing Date variables divided into Day, Month, Year:

var

  dYear  : string;

  dMonth : string;

  dDay   : string;

begin

  dYear := '1998';

  dMonth := '06';

  dDay := '31';

  Crpe1.GroupSelection.Formula[0] := 'Maximum({company.STARTDATE},{company.STATE}) = Date(' + dYear + ',' + dMonth + ',' + dDay + ')';

5. Passing Date variables entered in Edit boxes:

var

  dYear  : string;

  dMonth : string;

  dDay   : string;

  dWhole : string;

begin

  dYear := Edit1.Text;

  dMonth := Edit2.Text;

  dDay := Edit3.Text;

  dWhole := 'Date(' + dYear + ',' + dMonth + ',' + dDay + ')';

  Crpe1.GroupSelection.Formula[0] := 'Maximum({company.STARTDATE},{company.STATE}) = ' + dWhole;


CopyFrom method

See also	Example

Applies to

GroupSelection

Declaration

procedure CopyFrom(Source: TCrpeGroupSelectionFormula);

Description

The CopyFrom method copies the GroupSelection property values from another TCrpeGroupSelectionFormula object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the GroupSelection property values to a temporary TCrpeGroupSelectionFormula object:

var

tempGroupSelection : TCrpeGroupSelectionFormula;

begin

tempGroupSelection := TCrpeGroupSelectionFormula.Create;

tempGroupSelection.CopyFrom(Crpe1.GroupSelection);

{...later, when finished with the temp object...}

tempGroupSelection.Free;

end;


Formulas

See also	Properties & Methods	Example

Declaration

property Formulas: TCrpeFormulas;

Type

TCrpeFormulas = class(TPersistent)

Description

The Formulas object contains all the properties that apply to Formulas in a Report.

•	The Name property specifies the Name of the Formula.

•	The Formula property holds the Formula text.

•	The default array property Item, and the ItemIndex property, can be used to navigate through the various Formulas that may be stored in the Formulas object.

•	Formulas may be retrieved from the Report via the Retrieve method.

•	The Add / Delete methods can be used instead of Retrieve/Clear to manually add and remove items in the Formulas object.

•	The Check method provides an easy way of checking the syntax of the Formula text before running the Report.

Formulas are a very powerful feature in Crystal Reports and besides their normal summary functions, can be used at runtime to control everything from Section and Field formatting to Grouping and Sorting.


Formulas - See also
Related

GroupSelection

ParamFields

Selection

Using Variables with Formulas

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Formulas - Properties & Methods
Formulas:

Properties & Methods

Formulas	TCrpe Component

Properties

Formula

Key

Name

Navigation

Item

ItemIndex

Methods

Check

Clear

CopyFrom

Count

IndexOf

Retrieve

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


Formulas - Example
Example

The following procedures show how easy it is to use the features of the new VCL in the Delphi environment.  The components placed on the Form are:

TListBox	- lbFormulaNames

TMemo	- memoFormulas

TButton	- FormulaCheck

The Button click event is associated with this procedure:

procedure btnFormulaCheckClick(Sender: TObject);

The ListBox click event is associated with this procedure:

procedure lbFormulaNamesClick(Sender: TObject);

The Memo change event is associated with this procedure:

procedure memoFormulasChange(Sender: TObject);

And this procedure initializes the Form's components with data from the Report:

procedure UpdateForm;

The Formula names are loaded into the ListBox in the UpdateForm procedure.  When a name is clicked in the ListBox, the Memo component becomes updated with the Formula Text associated with that formula name.  When the formula is edited in the memo, it is written back to the Crystal component's Formula Text property.  Finally, when the button is clicked, the Formula is checked to see if the syntax is good.

{UpdateForm procedure}

procedure TfrmMain.UpdateForm;

var

  cnt: smallint;

begin

  lbFormulaNames.Clear;

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Formulas.Retrieve;

  {Loop through Formulas and add Formula Names to ListBox}

  if Crpe1.Formulas.Count > 0 then

  begin

    for cnt := 0 to (Crpe1.Formulas.Count - 1) do

    begin

      Crpe1.Formulas[cnt];

      lbFormulaNames.Items.Add(Crpe1.Formulas.Name);

    end;

    lbFormulaNames.ItemIndex := 0;

    lbFormulaNamesClick(Self);

  end;

end;

{lbFormulaNamesClick procedure}

{Notice how we disable the Memo OnChange event.  If we

don't do this, it will write back the first line to the

VCL, overwriting the rest of the formula stored there}

procedure TfrmMain.lbFormulaNamesClick(Sender: TObject);

begin

  Crpe1.Formulas[lbFormulaNames.ItemIndex];

  {Disable the OnChange event!}

  memoFormulas.OnChange := nil;

  {Copy the Formula from the VCL}

  memoFormulas.Lines.Assign(Crpe1.Formulas.Formula);

  {Re-enable the OnChange event}

  memoFormulas.OnChange := memoFormulasChange;

end;

{memoFormulasChange procedure}

procedure TfrmMain.memoFormulasChange(Sender: TObject);

begin

  Crpe1.Formulas.Formula.Assign(memoFormulas.Lines);

end;

{btnFormulaCheckClick procedure}

procedure TfrmMain.btnFormulaCheckClick(Sender: TObject);

begin

  if Crpe1.Formulas.Check then

    ShowMessage('Formula is good')

  else

    ShowMessage('Formula has an error');

end;


Item property

See also	Example

Applies to

Formulas

Declaration

property Item[const nIndex: integer]: TCrpeFormulas;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the Formulas object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  Formulas[2] is the same as Formulas.Item[2].

•	Item returns a reference to the Formulas object, so the Formulas properties can be used right after the subscript: Formulas[2].Name := 'Formula1';


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Formulas.Retrieve;

{Set Formulas to the 3rd formula}

Crpe1.Formulas.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Formulas.Retrieve;

{Set Formulas to the 3rd formula}

Crpe1.Formulas[2];


ItemIndex property

See also	Example

Applies to

Formulas

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current Formulas item number, or set the Formulas object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (Formulas[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the Formulas object is pointing to the first Formula:

if Crpe1.Formulas.ItemIndex <> 0 then

  Crpe1.Formulas[0];


Name property

See also	Example

Applies to

Formulas

Declaration

property Name: TCrFormulaName;

Type

TCrFormulaName = string;

Description

The Name property specifies the Name of the Formula.  It is a key property, and therefore serves as a lookup; that is, assigning it a value will cause the Formulas object to point to the item that has a Formula Name with the same value.  Before using the Name property to navigate through the Formulas, the Retrieve method should be called, or the manual Add method.

•	The @ sign is not used when designating a Formula name in this property.

•	This property cannot be used to create new Formulas. Only Formulas that already exist in the Report can be specified.


Name property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Name property - Example
Example

The following code uses the Formula Name property to point the Formulas object to the specified formula.  It then assigns a new formula text to the Formula property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Formulas.Retrieve;

{Set the Formulas object to the "Formula One" item}

Crpe1.Formulas.Name := 'Formula One';

{Assign a new formula to the Formula property}

Crpe1.Formulas.Formula.Text := '{table.NUM} * 100';

Crpe1.Output := toWindow;

Crpe1.Execute;


Formula property

See also	Example

Applies to

Formulas

Declaration

property Formula: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The Formula property contains the actual text of the Formula.  To assign a new value to the Formula property, any of the following methods can be used (or any other method that is valid for a StringList):

1)  Crpe1.Formulas.Formula.Clear;

    Crpe1.Formulas.Formula.Add('new text');

2)  Crpe1.Formulas.Formula.Text := 'new text';

3)  Crpe1.Formulas.Formula.Clear;

    Crpe1.Formulas.Formula[0] := 'new text';

4)  Crpe1.Formulas.Formula.SetText(PChar('new text'));

•	The new Formula string must conform to Seagate Crystal Reports syntax requirements.

•	To clear a Formula in a Report, so that it is blank, use the CrEmptyStr constant:

{When the Report is run, the first Formula will be cleared in the Report}

Crpe1.Formulas[0].Formula.Text := CrEmptyStr;

See also Using Variables with Formulas.


Formula property - See also
Related

Name

Using Variables with Formulas

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Formula property - Example
Example

The following code shows how the Formula property is used to store a new formula.

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Formulas.Retrieve;

Crpe1.Formulas[0];

Crpe1.Formulas.Formula.Text := '({company.SALES} * 10) / 100';

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

Formulas

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Formulas object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

Formulas

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Check method

See also	Example

Applies to

Formulas

Declaration

function Check: boolean;

Description

The Check method can be used to check the syntax of a Formula before running the Report.  Check returns a boolean value:

True	: Formula is good.

False	: Formula has an error.


Check method - See also
Related

Formula

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Check method - Example
Example

The following code loops through all the Formulas, checking each one:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Formulas.Retrieve;

for cnt := 0 to (Crpe1.Formulas.Count - 1) do

begin

  if not Crpe1.Formulas[cnt].Check then

    ShowMessage('Error in Formula #' + IntToStr(cnt));

end;

end;


Count method

See also	Example

Applies to

Formulas

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the Formulas object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Formulas.Retrieve;

for cnt := 0 to (Crpe1.Formulas.Count - 1) do

  Crpe1.Formulas[cnt].Formula.Text := '2001';

end;


Retrieve method

See also	Example

Applies to

Formulas

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Formulas from the Report and stores them in Formulas object.  If no Formulas were found, the call returns False.  Be aware that calling Retrieve will first cause the Formulas object to be cleared, so any current information stored in it will be removed.

Note

Since the Formulas object also applies to Subreports, the Retrieve method will obtain the Formulas for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the Formulas information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate Formulas information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Formulas.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.Formulas.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

Formulas

Declaration

function Send: boolean;

Description

The Send method sends the Formulas values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the Formulas settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.Formulas.Send;


Add method

See also	Example

Applies to

Formulas

Declaration

function Add(FormulaName: TCrFormulaName): integer;

Type

TCrFormulaName = string;

Description

The Add method adds an item to the Formulas object and sets the internal index to that item.  It requires a Formula name as a parameter, which should be a name corresponding to a Formula in the Report.  Formula Names are expressed as they are written in Crystal Reports, but without the "@" symbol that gets added when they are used within other Formulas.  If the Add method is used, the steps to using Formulas are:

1. Add an item to the Formulas object (you must specify the Formula name).

2. Fill the Text property with a formula.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Formula names are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the Formulas object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Formula Name - must be same as in Report}

Crpe1.Formulas.Add('Formula2');

Crpe1.Formulas.Formula.Text := '2001';

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

Formulas

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the Formulas object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the Formulas object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the Formulas of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the Formulas properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.Formulas.Clear;

This code clears the Formulas properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.Formulas.Clear;

end;


Delete method

See also	Example

Applies to

Formulas

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the Formulas object.  The "nIndex" parameter represents the number of the item in the Formulas object.

Note

Delete will not remove the Formula from the Report, it will just remove it from the Crystal VCL.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the Formulas object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Formula Name - must be same as in Report}

Crpe1.Formulas.Add('Formula2');

Crpe1.Formulas.Formula.Text := '2001';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.Formulas.Delete(0);


Using Variables with Formulas

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;

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 Add method

Crpe1.Formulas.Formula.Clear;

Crpe1.Formulas.Formula.Add('Date(1998,01,01)');

Examples

A. 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.

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 has the value 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}

B. 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}

C. 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}

  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}


CopyFrom method

See also	Example

Applies to

Formulas

Declaration

procedure CopyFrom(Source: TCrpeFormulas);

Description

The CopyFrom method copies the Formulas property values from another TCrpeFormulas object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Formulas property values to a temporary TCrpeFormulas object:

var

tempFormulas : TCrpeFormulas;

begin

tempFormulas := TCrpeFormulas.Create;

tempFormulas.CopyFrom(Crpe1.Formulas);

{...later, when finished with the temp object...}

tempFormulas.Free;

end;


IndexOf method

See also	Example

Applies to

Formulas

Declaration

function IndexOf(FormulaName: TCrFormulaName): integer;

Type

TCrFormulaName = string;

Description

The IndexOf method takes a Formula name and returns the index position of the Formula item in the current Formulas object.

After the Retrieve method has been called, the Formulas object contains one item for each Formula in the Report.  The IndexOf method can be used to determine if a given Formula Name actually exists in the Formulas object before trying to access it.


IndexOf method - See also
Related

Name

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

The following code illustrates the use of the IndexOf method to locate a specific Formula item by it's name:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Formulas.Retrieve;

{Find a specific formula}

nItem := Crpe1.Formulas.IndexOf('Percentage Sales');

{If it exists...}

if nItem > -1 then

begin

with Crpe1.Formulas[nItem] do

begin

    {Calculate 20% of SALES}

  Formula.Text := '{company.SALES} * .20';

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


SortFields

See also	Properties & Methods	Example

Declaration

property SortFields: TCrpeSortFields;

Type

TCrpeSortFields = class(TPersistent);

Description

The SortFields object contains the properties needed to set and modify the Record Sort Order for a Report.  The main properties are:

•	The Number property contains the SortField number, which is zero-based.

•	The Field property contains the actual SortField string.  Remember to enclose field names in braces: {company.STATE}.  If you sort on a formula field, use the @ sign before the formula name: {@FORMULANAME}.

•	The Direction property specifies the sorting direction, either sdDescending, sdAscending, or sdDefault.

•	The DeleteSF property can be used to delete a SortField.  Remember that when a SortField is set to be deleted, it is removed from the Report in memory, when the Report is run.  To reference it again, the Report would have to be loaded again, or the SortField would have to be added back using the Add method.

•	The Retrieve method will load the Crystal component with the SortFields currently in the Report.

•	The Count method will return the number of SortFields items stored in the SortFields object.

•	The Item and ItemIndex properties can be used to navigate through the items in the SortFields object.


SortFields - See also
Related

GroupCondition

GroupOptions

GroupSortFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SortFields - Properties & Methods
SortFields:

Properties & Methods

SortFields	TCrpe Component

Properties

DeleteSF

Direction

Field

Key

Number

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


SortFields - Example
Example

The code below loops through all the SortFields, changing the sort direction to descending:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SortFields.Retrieve;

for cnt := 0 to (Crpe1.SortFields.Count - 1) do

  Crpe1.SortFields[cnt].Direction := sdDescending;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


DeleteSF property

See also	Example

Applies to

SortFields

Declaration

property DeleteSF: boolean;

Description

The DeleteSF property can be used to remove a SortField from a Report.  The SortField is not actually removed from the Report until the Execute method is called.  After Execute is called, the SortField is also removed from the VCL.

Note

DeleteSF is not the same as Delete.  Delete removes a SortField item from the SortFields object, not from the Report.


DeleteSF property - See also
Related

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DeleteSF property - Example
Example

This example will remove the second SortField from a Report when that Report is run:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SortFields.Retrieve;

Crpe1.SortFields[1].DeleteSF := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


Direction property

See also	Example

Applies to

SortFields

Declaration

property Direction: TCrSortDirection;

Type

TCrSortDirection = (sdDescending, sdAscending, sdDefault);

Description

The Direction property determines the Sort Order, which can either be sdDescending (9..0, Z..A), sdAscending (0..9, A..Z), or sdDefault (no change).


Direction property - See also
Related

Field

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Direction property - Example
Example

This example changes the Sort Order of the first SortField to ascending:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SortFields.Retrieve;

Crpe1.SortFields[0].Direction := sdAscending;

Crpe1.Output := toWindow;

Crpe1.Execute;


Field property

See also	Example

Applies to

SortFields

Declaration

property Field: string;

Description

The Field property specifies the field that will control sorting.  Sort fields can be database fields or formula fields.

•	Enclose field names in braces: {company.STATE}.

•	If a formula field is specified, use the @ sign before the formula name: {@FormulaName}.


Field property - See also
Related

Direction

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Field property - Example
Example

This example changes the second SortField to be sorted on a formula field called FormulaOne:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SortFields.Retrieve;

Crpe1.SortFields[1].Field := '{@FormulaOne}';

Crpe1.Output := toWindow;

Crpe1.Execute;


Item property

See also	Example

Applies to

SortFields

Declaration

property Item[const nIndex: integer]: TCrpeSortFields;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the SortFields object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  SortFields[2] is the same as SortFields.Item[2].

•	Item returns a reference to the SortFields object, so the SortFields properties can be used right after the subscript: SortFields[2].Field := '{company.STATE}';


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SortFields.Retrieve;

{Set SortFields object to the 3rd item}

Crpe1.SortFields.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SortFields.Retrieve;

{Set SortFields object to the 3rd item}

Crpe1.SortFields[2];


ItemIndex property

See also	Example

Applies to

SortFields

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current SortFields item number, or set the SortFields object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (SortFields[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the SortFields object is pointing to the first SortField:

if Crpe1.SortFields.ItemIndex <> 0 then

  Crpe1.SortFields[0];


Number property

See also	Example

Applies to

SortFields

Declaration

property Number: TCrSortFieldsNumber;

Description

The Number property specifies the actual SortField number.  It is zero-based, so the first SortField in a Report is zero (0).  Number is a key property, and therefore serves as a lookup; that is, assigning it a value will cause the SortFields object to point to the item that has a SortField Number with the same value.  Before using the Number property to navigate through the SortFields, the Retrieve method should be called, or the manual Add method.


Number property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

This example uses the Number property to cause the SortFields object to point to the second SortField item:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SortFields.Retrieve;

Crpe1.SortFields.Number := 1;

Crpe1.SortFields.Direction := sdAscending;

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

SortFields

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the SortFields object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

SortFields

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

SortFields

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the SortFields object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SortFields.Retrieve;

  for cnt := 0 to (Crpe1.SortFields.Count - 1) do

    Crpe1.SortFields[cnt].Direction := sdDescending;

end;


Retrieve method

See also	Example

Applies to

SortFields

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SortFields from the Report and stores them in the SortFields object.  If no SortFields were found, the call returns False.  Be aware that calling Retrieve will first cause the SortFields object to be cleared, so any current information stored in it will be removed.

Note

Since the SortFields object also applies to Subreports, the Retrieve method will obtain the SortFields for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the SortFields information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate SortFields information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SortFields.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.SortFields.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

SortFields

Declaration

function Send: boolean;

Description

The Send method sends the SortFields values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the SortFields settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SortFields.Send;


Add method

See also	Example

Applies to

SortFields

Declaration

function Add(SortFieldNumber: TCrSortFieldsNumber): integer;

Type

TCrSortFieldsNumber = integer;

Description

The Add method does two things:

1. Adds an item to the SortFields object.

2. Sets the internal index of the SortFields object to that new item.

It requires a SortField number as a parameter, which should be a number corresponding to a SortField in the Report (although it is possible with SortFields to add a new item that is not currently in the Report).  SortFields are numbered starting from zero.  If the Add method is used, the steps to using SortFields are:

1. Add an item to the SortFields object (you must specify the SortField number).

2. Fill the item's properties (Direction, Field, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Unlike most of the other VCL properties which can only modify Report values, SortFields and GroupSortFields can be used to add items in the Report that have not been previously designed into it.  However, care must be taken that the item added is the next available number in sequence.  In other words, if a Report contains 3 SortFields, and a new, fourth SortField is to be added, it must be assigned a number of 3, since the existing ones will be numbered 0, 1, and 2.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the SortField numbers are correct for the current Report.  However, for adding new SortFields that are not currently in the Report, the Add method must be used.  When using Add in this way, the SortField number specified must be one greater than the highest SortField number currently in the Report (or one higher than the SortField number in the VCL if more than one SortField is being added).


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

Here is a simple procedure that locates the next available SortField number when Adding a new SortField to the SortFields object:

procedure AddSortField;

var

  cnt1,cnt2 : integer;

begin

  {Locate the first available number}

  cnt1 := 0;  {stores the new number to be checked}

  cnt2 := 0;  {cycles through the list for each new number}

  while cnt2 < Crpe1.SortFields.Count do

  begin

    if Crpe1.SortFields[cnt2].Number = cnt1 then

    begin

      Inc(cnt1);

      cnt2 := 0;

    end

    else

      Inc(cnt2);

  end;

  Crpe1.SortFields.Add(cnt1);

end;

This example retrieves the SortFields from a Report, sets them all to be deleted, and then adds a new SortField:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SortFields.Retrieve;

  {Set all SortFields to be deleted. They are not

   actually deleted until Execute is called}

  for cnt := 0 to (Crpe1.SortFields.Count - 1) do

    Crpe1.SortFields[cnt].DeleteSF := True;

  {Add a new SortField}

  Crpe1.SortFields.Add(Crpe1.SortFields.Count);

  Crpe1.SortFields.Field := '{company.STATE}';

  Crpe1.SortFields.Direction := sdAscending;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Clear method

See also	Example

Applies to

SortFields

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the SortFields object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the SortFields object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the SortFields of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the SortFields properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.SortFields.Clear;

This code clears the SortFields properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.SortFields.Clear;

end;


Delete method

See also	Example

Applies to

SortFields

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the SortFields object.  The "nIndex" parameter represents the number of the item in the SortFields object, which may not be the same as the SortFields Number value.

Note

Delete will not remove the SortField from the Report, it will just remove it from the Crystal VCL.  Set the DeleteSF property to remove a SortField from the Report.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the SortFields object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify SortField Number}

Crpe1.SortFields.Add(0);

Crpe1.SortFields.Field := '{company.STATE}';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SortFields.Delete(0);


CopyFrom method

See also	Example

Applies to

SortFields

Declaration

procedure CopyFrom(Source: TCrpeSortFields);

Description

The CopyFrom method copies the SortFields property values from another TCrpeSortFields object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the SortFields property values to a temporary TCrpeSortFields object:

var

tempSortFields : TCrpeSortFields;

begin

tempSortFields := TCrpeSortFields.Create;

tempSortFields.CopyFrom(Crpe1.SortFields);

{...later, when finished with the temp object...}

tempSortFields.Free;

end;


GroupSortFields

See also	Properties & Methods	Example

Declaration

property GroupSortFields: TCrpeGroupSortFields;

Type

TCrpeGroupSortFields = class(TPersistent)

Description

The GroupSortFields object contains the properties needed to set and modify the sorting of the Groups in a Report.  The main properties are:

•	The Number property contains the GroupSortField number, which is zero-based.

•	The Field property contains the actual GroupSortField string.  This should be a Summary field, although it does not need to be a Summary field that already exists in the Report.  Any field names used in the Field property should be enclosed  in braces: {company.STATE}.

•	The Direction property specifies the sorting direction, either sdDescending, sdAscending, or sdDefault.

•	The DeleteGSF property can be used to delete a GroupSortField.  When a GroupSortField is set to be deleted, and the Report is run, the deleted GroupSortField will no longer be in the Report that is currently loaded in memory, or the Crystal component either.  To reference it again, the Report will have to be re-loaded, or the Add method will have to be used to add it back.

•	The Retrieve method will fetch the GroupSortFields currently in the Report.

•	The Count method will return the number of GroupSortFields items stored in the GroupSortFields object.

•	The Item and ItemIndex properties can be used to navigate through the items in the GroupSortFields object.

Note on Summary fields

Summary fields are usually constructed in this fashion:

SummaryFunction(DatabaseField,GroupingField)

so they usually look something like this:

Sum({company.SALES},{company.STATE})

This would read: "Sum of the Company's Sales per State".  The last parameter must be a field that the Report is grouped on.


GroupSortFields - See also
Related

GroupCondition

GroupOptions

SortFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupSortFields - Properties & Methods
GroupSortFields:

Properties & Methods

GroupSortFields	TCrpe Component

Properties

DeleteGSF

Direction

Field

Key

Number

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


GroupSortFields - Example
Example

The code below shows how to change the Field value of a GroupSortField, and set the Sort Direction to descending:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSortFields.Retrieve;

Crpe1.GroupSortFields[2];

Crpe1.GroupSortFields.Field := 'Sum({company.SALES},{company.STATE})';

Crpe1.GroupSortFields.Direction := sdDescending;

Crpe1.Execute;


DeleteGSF property

See also	Example

Applies to

GroupSortFields

Declaration

property DeleteGSF: boolean;

Description

The DeleteGSF property can be used to remove a GroupSortField from a Report.  The GroupSortField is not actually removed from the Report until the Execute method is called.  After Execute is called, the GroupSortField is also removed from the VCL.

Note

DeleteGSF is not the same as Delete.  Delete removes a GroupSortField item from the GroupSortFields object, not from the Report.


DeleteGSF property - See also
Related

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DeleteGSF property - Example
Example

This example will remove the second GroupSortField from a Report when that Report is run:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSortFields.Retrieve;

Crpe1.GroupSortFields[1].DeleteGSF := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


Direction property

See also	Example

Applies to

GroupSortFields

Declaration

property Direction: TCrSortDirection;

Type

TCrSortDirection = (sdDescending, sdAscending, sdDefault);

Description

The Direction property determines the Sort Order, which can either be sdDescending (9..0, Z..A), sdAscending (0..9, A..Z), or sdDefault (no change).


Direction property - See also
Related

Field

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Direction property - Example
Example

This example changes the Sort Order of the first GroupSortField to ascending:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSortFields.Retrieve;

Crpe1.GroupSortFields[0].Direction := sdAscending;

Crpe1.Output := toWindow;

Crpe1.Execute;


Field property

See also	Example

Applies to

GroupSortFields

Declaration

property Field: string;

Declaration

property Field: string;

Description

The Field property specifies the summary field that will control sorting.  Summary fields are usually constructed in this fashion:

SummaryFunction(DatabaseField,GroupingField)

so they usually look something like this:

Sum({company.SALES},{company.STATE})

This would read: "Sum of the Company's Sales per State".  The last parameter must be a field that the Report is grouped on.

•	Enclose field names in braces: {company.STATE}.

•	If a formula field is the grouping field, use the @ sign before the formula name: {@FormulaName}.


Field property - See also
Related

Direction

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Field property - Example
Example

This example changes the second GroupSortField:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSortFields.Retrieve;

Crpe1.GroupSortFields[1].Field := 'Sum({company.SALES},{company.STATE})';

Crpe1.Output := toWindow;

Crpe1.Execute;


Item property

See also	Example

Applies to

GroupSortFields

Declaration

property Item[const nIndex: integer]: TCrpeGroupSortFields;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the GroupSortFields object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  GroupSortFields[2] is the same as GroupSortFields.Item[2].

•	Item returns a reference to the GroupSortFields object, so the GroupSortFields properties can be used right after the subscript: GroupSortFields[2].Direction := sdAscending;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSortFields.Retrieve;

{Set GroupSortFields object to the 3rd item}

Crpe1.GroupSortFields.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSortFields.Retrieve;

{Set GroupSortFields object to the 3rd item}

Crpe1.GroupSortFields[2];


ItemIndex property

See also	Example

Applies to

GroupSortFields

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GroupSortFields item number, or set the GroupSortFields object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (GroupSortFields[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the GroupSortFields object is pointing to the first GroupSortFields item:

if Crpe1.GroupSortFields.ItemIndex <> 0 then

  Crpe1.GroupSortFields[0];


Number property

See also	Example

Applies to

GroupSortFields

Declaration

property Number: TCrGroupSortFieldsNumber;

Type

TCrGroupSortFieldsNumber = integer;

Description

The Number property specifies the Number of the GroupSortField.  It is a key property, and therefore serves as a lookup; that is, assigning it a value will cause the GroupSortFields object to point to the item that has a GroupSortField Number with the same value.  Before using the Number property to navigate through the GroupSortFields, the Retrieve method should be called, or the manual Add method.


Number property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

This example uses the Number property to cause the GroupSortFields object to point to the second GroupSortField item:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSortFields.Retrieve;

Crpe1.GroupSortFields.Number := 1;

Crpe1.GroupSortFields.Direction := sdAscending;

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

GroupSortFields

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the GroupSortFields object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

GroupSortFields

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

GroupSortFields

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the GroupSortFields object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GroupSortFields.Retrieve;

  for cnt := 0 to (Crpe1.GroupSortFields.Count - 1) do

    Crpe1.GroupSortFields[cnt].Direction := sdDescending;

end;


Retrieve method

See also	Example

Applies to

GroupSortFields

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the GroupSortFields from the Report and stores them in the GroupSortFields object.  If no GroupSortFields were found, the call returns False.  Be aware that calling Retrieve will first cause the GroupSortFields object to be cleared, so any current information stored in it will be removed.

Note

Since the GroupSortFields object also applies to Subreports, the Retrieve method will obtain the GroupSortFields for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the GroupSortFields information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate GroupSortFields information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSortFields.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.GroupSortFields.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

GroupSortFields

Declaration

function Send: boolean;

Description

The Send method sends the GroupSortFields values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the GroupSortFields settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.GroupSortFields.Send;


Add method

See also	Example

Applies to

GroupSortFields

Declaration

function Add(GroupSortFieldNumber: TCrGroupSortFieldsNumber): integer;

Type

TCrGroupSortFieldsNumber = integer;

Description

The Add method does two things:

1. Adds an item to the GroupSortFields object.

2. Sets the internal index of the GroupSortFields object to that new item.

It requires a GroupSortField number as a parameter, which should be a number corresponding to a GroupSortField in the Report (although it is possible with GroupSortFields to add a new item that is not currently in the Report).  GroupSortFields are numbered starting from zero.  If the Add method is used, the steps to using GroupSortFields are:

1. Add an item to the GroupSortFields object (you must specify the GroupSortField number).

2. Fill the item's properties (Field, Direction, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Unlike most of the other VCL properties which can only modify Report values, SortFields and GroupSortFields can be used to add items in the Report that have not been previously designed into it.  However, care must be taken that the item added is the next available number in sequence.  In other words, if a Report contains 3 GroupSortFields, and a new, fourth GroupSortField is to be added, it must be assigned a number of 3, since the existing ones will be numbered 0, 1, and 2.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the GroupSortField numbers are correct for the current Report.  However, for adding new GroupSortFields that are not currently in the Report, the Add method must be used.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

Here is a simple procedure that locates the next available GroupSortField number when Adding a new GroupSortField to the GroupSortFields object:

procedure AddGroupSortField;

var

  cnt1,cnt2 : integer;

begin

  {Locate the first available number}

  cnt1 := 0;  {stores the new number to be checked}

  cnt2 := 0;  {cycles through the list for each new number}

  while cnt2 < Crpe1.GroupSortFields.Count do

  begin

    if Crpe1.GroupSortFields[cnt2].Number = cnt1 then

    begin

      Inc(cnt1);

      cnt2 := 0;

    end

    else

      Inc(cnt2);

  end;

  Crpe1.GroupSortFields.Add(cnt1);

end;

This example retrieves the GroupSortFields from a Report, sets them all to be deleted, and then adds a new GroupSortField:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GroupSortFields.Retrieve;

  {Set all GroupSortFields to be deleted. They are not

   actually deleted until Execute is called}

  for cnt := 0 to (Crpe1.GroupSortFields.Count - 1) do

    Crpe1.GroupSortFields[cnt].DeleteGSF := True;

  {Add a new SortField}

  Crpe1.GroupSortFields.Add(Crpe1.GroupSortFields.Count);

  Crpe1.GroupSortFields.Field := 'Sum({company.SALES},{company.STATE})';

  Crpe1.GroupSortFields.Direction := sdAscending;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Clear method

See also	Example

Applies to

GroupSortFields

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GroupSortFields object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the GroupSortFields object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the GroupSortFields of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the GroupSortFields properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.GroupSortFields.Clear;

This code clears the GroupSortFields properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.GroupSortFields.Clear;

end;


Delete method

See also	Example

Applies to

GroupSortFields

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the GroupSortFields object.  The "nIndex" parameter represents the number of the item in the GroupSortFields object, which may not be the same as the GroupSortFields Number value.

Note

Delete will not remove the GroupSortField from the Report, it will just remove it from the Crystal VCL.  Set the DeleteGSF property to remove a GroupSortField from the Report.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the GroupSortFields object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify a GroupSortFields Number}

Crpe1.GroupSortFields.Add(0);

Crpe1.GroupSortFields.Field := 'Sum({company.SALES},{company.STATE})';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.GroupSortFields.Delete(0);


CopyFrom method

See also	Example

Applies to

GroupSortFields

Declaration

procedure CopyFrom(Source: TCrpeGroupSortFields);

Description

The CopyFrom method copies the GroupSortFields property values from another TCrpeGroupSortFields object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the GroupSortFields property values to a temporary TCrpeGroupSortFields object:

var

tempGroupSortFields : TCrpeGroupSortFields;

begin

tempGroupSortFields := TCrpeGroupSortFields.Create;

tempGroupSortFields.CopyFrom(Crpe1.GroupSortFields);

{...later, when finished with the temp object...}

tempGroupSortFields.Free;

end;


GroupCondition

See also	Properties & Methods	Example

Declaration

property GroupCondition: TCrpeGroupCondition;

Type

TCrpeGroupCondition = class(TPersistent)

Description

The GroupCondition object contains the properties that refer to the Grouping fields in a Report.  Unlike SortFields and GroupSortFields, a GroupCondition cannot be added or deleted from a Report at runtime.  However, it is possible to set all the Groups to the same field, thus in effect nullifying all but one of them.  The main properties in GroupCondition are:

•	The Number property represents the actual Group number in the Report, and unlike most of the other numbering in the component, Groups start with number 1.  This is easier to remember, since in the Crystal Reports Designer, there is no such thing as Group 0.

•	The Field property specifies the actual field value that the Group is based on, which could be a database field, or a formula field.  Remember to enclose database fields in braces {}, and to prefix formula names with the @ symbol.

•	The Condition property specifies the condition that the Group changes on

•	The Direction property specifies in which order the Groups will be sorted.

•	The Retrieve method can be used to retrieve and fill the GroupCondition object with values from the Report.

•	The Count method will return how many items are in the GroupCondition object (ie. how many groups are in the Report), and can be used for looping constructs.

•	As well as the Number property, the default array property Item and the ItemIndex property can be used to navigate through the items in the GroupCondition object.

Note

If you have Crystal Reports 6.0, GroupOptions can be used instead of GroupCondition.  It has all the functionality of GroupCondition, plus TopN properties, and other features as well.


GroupCondition - See also
Related

GroupOptions

GroupSortFields

SortFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupCondition - Properties & Methods
GroupCondition:

Properties & Methods

GroupCondition	TCrpe Component

Properties

Condition

Direction

Field

GroupType

Key

Number

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


GroupCondition - Example
Example

This sample retrieves the GroupCondition values from the Report, and sets the first Group to the {company.STATE} field, ascending:

Crpe1.ReportName := 'C:\Company.rpt';

with Crpe1.GroupCondition do

begin

  Retrieve;

  Number := 1;

  Field := '{company.STATE}';

    Condition := AnyChange;

    Direction := gcAscending;

  end;

  Crpe1.Execute;


Condition property

See also	Example

Applies to

GroupCondition

Declaration

property Condition: TCrGroupCondition;

Types

TCrGroupCondition = (AnyChange, dateDaily, dateWeekly, dateBiWeekly, dateSemiMonthly, dateMonthly, dateQuarterly, dateSemiAnnually, dateAnnually, boolToYes, boolToNo, boolEveryYes, boolEveryNo, boolNextIsYes, boolNextIsNo, timeBySecond, timeByMinute, timeByHour, timeByAMPM);

Description

The Condition property determines when a new Group is begun.  Groups based on Date, Boolean, Time, or DateTime fields are the only ones that have specific Condition values.  All other types of fields use AnyChange as the Group Condition value.

For Groups based on Date fields, the options are:

dateDaily	- Triggers a grouping for every Day.

dateWeekly	- Triggers a grouping for every Week.

dateBiWeekly	- Triggers a grouping for every second Week.

dateSemiMonthly	- Triggers a grouping for every half Month.

dateMonthly	- Triggers a grouping for every Month.

dateQuarterly	- Triggers a grouping for every quarter Year.

dateSemiAnnually	- Triggers a grouping for every half Year.

dateAnnually	- Triggers a grouping for every Year.

For Groups based on Boolean fields, the options are:

boolToYes	- Triggers a grouping every time the Group field value changes from No to Yes.

boolToNo	- Triggers a grouping every time the Group field value changes from Yes to No.

boolEveryYes	- Triggers a grouping every time the Group field value is Yes.

boolEveryNo	- Triggers a grouping every time the Group field value is No.

boolNextIsYes	- Triggers a grouping every time the next value in the Group field is Yes.

boolNextIsNo	- Triggers a grouping every time the next value in the Group field is No.

For Groups based on Time or DateTime fields, the options are:

timeBySecond	- Triggers a grouping every time the Group field value changes seconds.

timeByMinute	- Triggers a grouping every time the Group field value changes minutes.

timeByHour	- Triggers a grouping every time the Group field value changes hours.

timeByAMPM	- Triggers a grouping every time the Group field value changes from AM to PM.


Condition property - See also
Related

Direction

Field

GroupType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Condition property - Example
Example

The code below sets the first Group of a Report to a date field, with the condition for the Group set to "daily":

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupCondition.Retrieve;

Crpe1.GroupCondition[0].Field := '{invoice.DATE}';

Crpe1.GroupCondition[0].Condition := dateDaily;

Crpe1.GroupCondition[0].Direction := gcDescending;

Crpe1.Output := toWindow;

Crpe1.Execute;


Direction property

See also	Example

Applies to

GroupCondition

Declaration

property Direction: TCrGroupDirection;

Type

TCrGroupDirection = (gcDescending, gcAscending, gcOriginal, gcSpecified, gcDefault);

Description

The Direction property determines how the Groups will be sorted.  This does not affect the sorting of records within the Group, just the sorting of the actual Groups themselves.  For example, if your grouping field is {company.STATE} then the Direction would determine if the first group was AK (gcAscending) or WY (gcDescending).

The five Direction options are:

gcDescending	- Sorts data in descending order (Z to A, 9 to 1).

gcAscending	- Sorts data in ascending order (A to Z, 1 to 9).

gcOriginal	- Sorts data in its original order.

gcSpecified	- Sorts data in a specified order.

gcDefault	- No change from current Report settings.

Note

In order to use gcSpecified, there must be a specified order saved with the Report.  Specified order requires the creation of custom Groups, which cannot be done at runtime, so if these Groups do not exist, setting the Condition to gcSpecified will result in error 511, "Invalid Sort Direction".


Direction property - See also
Related

Condition

Field

GroupType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Direction property - Example
Example

The code below sets the first Group of a Report to a date field, with the condition for the Group set to "daily", and the direction to "descending":

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupCondition.Retrieve;

Crpe1.GroupCondition[0].Field := '{invoice.DATE}';

Crpe1.GroupCondition[0].Condition := dateDaily;

Crpe1.GroupCondition[0].Direction := gcDescending;

Crpe1.Output := toWindow;

Crpe1.Execute;


Field property

See also	Example

Applies to

GroupCondition

Declaration

property Field: string;

Description

The Field property specifies the database field or formula field that will control grouping.

•	Enclose field names in braces: {company.STATE}.

•	If a formula field is the grouping field, use the @ sign before the formula name: {@FormulaName}.


Field property - See also
Related

Condition

Direction

GroupType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Field property - Example
Example

The code below sets the first Group of a Report to a date field, with the condition for the Group set to "daily", and the direction to "descending":

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupCondition.Retrieve;

Crpe1.GroupCondition[0].Field := '{invoice.DATE}';

Crpe1.GroupCondition[0].Condition := dateDaily;

Crpe1.GroupCondition[0].Direction := gcDescending;

Crpe1.Output := toWindow;

Crpe1.Execute;


GroupType property

See also	Example

Applies to

GroupCondition

Declaration

property GroupType: TCrGroupType;

Type

TCrGroupType = (gtOther, gtDate, gtBoolean, gtTime);

Description

The GroupType property specifies the data type of the grouping field.

gtOther	- the field is any other data type other than Date or Boolean.

gtDate	- the field is of Date type.

gtBoolean	- the field is of Boolean type.

gtTime	- the field is of Time type.

Note

It is important that the GroupType match the Condition, ie. if GroupType is gtBoolean, then the Condition must be set to one of the Boolean conditions, or an error will occur.


GroupType property - See also
Related

Condition

Direction

Field

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupType property - Example
Example

The code below loops through all the GroupCondition items, and when it locates an item with GroupType of Date, then it changes the Condition that triggers the Group to "daily":

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupCondition.Retrieve;

for cnt := 0 to (Crpe1.GroupCondition.Count - 1) do

begin

  if Crpe1.GroupCondition[cnt].GroupType = gtDate then

    Crpe1.GroupCondition[cnt].Condition := dateDaily;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Item property

See also	Example

Applies to

GroupCondition

Declaration

property Item[const nIndex: integer]: TCrpeGroupCondition;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the GroupCondition object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  GroupCondition[2] is the same as GroupCondition.Item[2].

•	Item returns a reference to the GroupCondition object, so the GroupCondition properties can be used right after the subscript: GroupCondition[2].Direction := gcAscending;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupCondition.Retrieve;

{Set GroupCondition to the 3rd Group}

Crpe1.GroupCondition.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupCondition.Retrieve;

{Set GroupCondition to the 3rd Group}

Crpe1.GroupCondition[2];


ItemIndex property

See also	Example

Applies to

GroupCondition

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GroupCondition item number, or set the GroupCondition object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (GroupCondition[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the GroupCondition object is pointing to the first GroupCondition item:

if Crpe1.GroupCondition.ItemIndex <> 0 then

  Crpe1.GroupCondition[0];


Number property

See also	Example

Applies to

GroupCondition

Declaration

property Number: TCrGroupConditionNumber;

Type

TCrGroupConditionNumber = integer;

Description

The Number property specifies the Group Number.  Unlike most of the other properties, Number is one-based, therefore the first Group is number one (1).

•	Number is a key property, and therefore serves as a lookup; that is, assigning it a value will cause the GroupCondition object to point to the GroupCondition item that has a Number with the same value.

•	Before using the Number property to navigate through the GroupCondition, the Retrieve method should be called, or the manual Add method.


Number property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

This sample retrieves the GroupCondition values from the Report, and uses the Number property to set the first Group to the {company.STATE} field:

Crpe1.ReportName := 'C:\Company.rpt';

with Crpe1.GroupCondition do

begin

  Retrieve;

  Number := 1;

  Field := '{company.STATE}';

    Condition := AnyChange;

    Direction := gcAscending;

  end;

  Crpe1.Execute;


Create method

See also

Applies to

GroupCondition

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the GroupCondition object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

GroupCondition

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

GroupCondition

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the GroupCondition object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GroupCondition.Retrieve;

  for cnt := 0 to (Crpe1.GroupCondition.Count - 1) do

    Crpe1.GroupCondition[cnt].Direction := gcAscending;

end;


Retrieve method

See also	Example

Applies to

GroupCondition

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the GroupCondition information from the Report and stores it in the GroupCondition object.  If no GroupCondition information was found, the call returns False.  Be aware that calling Retrieve will first cause the GroupCondition object to be cleared, so any current information stored in it will be removed.

Note

Since the GroupCondition object also applies to Subreports, the Retrieve method will obtain the GroupCondition for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the GroupCondition information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate GroupCondition information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupCondition.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.GroupCondition.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

GroupCondition

Declaration

function Send: boolean;

Description

The Send method sends the GroupCondition values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the GroupCondition settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.GroupCondition.Send;


Add method

See also	Example

Applies to

GroupCondition

Declaration

function Add(GroupNumber: TCrGroupConditionNumber): integer;

Type

TCrGroupConditionNumber = integer;

Description

The Add method adds an item to the GroupCondition object and sets the internal index to that item.  It requires a GroupCondition number as a parameter, which should be a number corresponding to a Group in the Report.

•	Unlike most other properties, Groups are numbered starting from one (1), although the GroupCondition object is still zero-based (ie. GroupCondition[0].Number usually equals 1).

If the Add method is used, the steps to using GroupCondition are:

1. Add an item to the GroupCondition object (you must specify the Group number).

2. Fill the item's properties (Field, Direction, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the GroupCondition numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the GroupCondition object, instead of using Retrieve.  Remember that the first Group number that can be added is 1, not 0 as in most other cases:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Group Number}

Crpe1.GroupCondition.Add(1);

Crpe1.GroupCondition.Field := '{company.STATE}';

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

GroupCondition

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GroupCondition object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the GroupCondition object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the GroupCondition of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the GroupCondition properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.GroupCondition.Clear;

This code clears the GroupCondition properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.GroupCondition.Clear;

end;


Delete method

See also	Example

Applies to

GroupCondition

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the GroupCondition object.  The "nIndex" parameter represents the number of the item in the GroupCondition object, not the Group number.  Group numbers start with 1, whereas the first item in the GroupCondition object is item zero (0).

Note

Delete will not remove the GroupCondition from the Report, it will just remove it from the Crystal VCL.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the GroupCondition object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Group Number - must be same as in Report}

Crpe1.GroupCondition.Add(1);

Crpe1.GroupCondition.Field := '{company.STATE}';

Crpe1.Output := toWindow;

Crpe1.Execute;

{Delete an item.  Note that although the Group

Number specified was 1, the item to delete is

item 0 of the GroupCondition object}

Crpe1.GroupCondition.Delete(0);


CopyFrom method

See also	Example

Applies to

GroupCondition

Declaration

procedure CopyFrom(Source: TCrpeGroupCondition);

Description

The CopyFrom method copies the GroupCondition property values from another TCrpeGroupCondition object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the GroupCondition property values to a temporary TCrpeGroupCondition object:

var

tempGroupCondition : TCrpeGroupCondition;

begin

tempGroupCondition := TCrpeGroupCondition.Create;

tempGroupCondition.CopyFrom(Crpe1.GroupCondition);

{...later, when finished with the temp object...}

tempGroupCondition.Free;

end;


SectionFormat

See also	Properties & Methods	Example

Declaration

property SectionFormat: TCrpeSectionFormat;

Type

TCrpeSectionFormat = class(TPersistent)

Description

SectionFormat controls how the sections of a Report behave.  It is similar to AreaFormat, except that AreaFormat applies to all of the sections of the same type, whereas SectionFormat works on every sub-section individually.  Since Crystal Reports 5.0, each section of a Report can be split into sub-sections, for example, Details a, Details b, etc.  SectionFormat can be used to control each sub-section.

The Section naming format has been adopted from the Crystal Reports "short" section naming convention, so RHa means ReportHeader a, GH3b means GroupHeader 3b, etc.  See "About Section Names" for more information.

•	If the Retrieve method is used to get the Section information from the Report, the SectionFormat object will be automatically populated with valid Section names, which appear in the Section property.

•	If the manual Add method is used instead, the programmer will have to specify which section to add to the object.

•	The Count, Item, and ItemIndex properties can be used to navigate through the different Section items in the SectionFormat object.

•	The BackgroundColor property can be used to change the color of a Section.  It is a Delphi TColor type, and so the Delphi color constants can be used, or the Color value from the ColorDialog.

•	The FreeFormPlacement property determines whether the fields in a section are snapped to grid or not.

•	The Suppress property will cause a Section to be hidden so that it is not processed.  Drill-down is not possible on a suppressed Section (to Hide a Section so that drill-down is still available, use the AreaFormat property, Hide).

•	The KeepTogether property will prevent a Section from splitting on a page break.  This is not the same as Keep Group Together, which is available via the GroupOptions property, KeepTogether.

•	The NewPageAfter and NewPageBefore properties determine if a page break will happen after or before a particular Section.

•	The PrintAtBottomOfPage property will cause the Section to appear at the bottom of the page.

•	The ResetPageNAfter property will cause the Page Number to be reset after a particular Section.

•	The SuppressBlankSection property will cause a Section that has no data to be suppressed.  If any of the fields in the Section have spaces in them, the Section will not be considered blank.

•	The UnderlaySection property will cause the Section to be displayed under the next Section, like layering two transparencies on top of each other.

•	The SectionAsCode property offers the ability to treat the Section name as a Section Code Number, which can be useful for doing mathematical expressions to filter out certain sections.

•	The SectionType method returns just the first characters of the Section name, so for GH1 (Group Header 1), the SectionType would be GH (Group Header).

Limitations

Main Report - For Page Header (PH) and Page Footer (PF) sections, the following options do not apply (setting them will have no effect on the Report):

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

Subreports - For Report Header b (RHb) and Report Footer b (RFb) sections, the following options do not apply (setting them will have no effect on the Report):

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage


SectionFormat - See also
Related

AreaFormat

AreaFormatFormulas

SectionFormatFormulas

SectionFont

SectionHeight

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionFormat - Properties & Methods
SectionFormat:

Properties & Methods

SectionFormat	TCrpe Component

Properties

BackgroundColor

FreeFormPlacement

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

Key

Section

SectionAsCode

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


SectionFormat - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets various options for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

begin

Crpe1.SectionFormat[cnt].BackgroundColor := clRed;

Crpe1.SectionFormat[cnt].FreeFormPlacement := cTrue;

Crpe1.SectionFormat[cnt].KeepTogether := cTrue;

Crpe1.SectionFormat[cnt].NewPageAfter := cFalse;

Crpe1.SectionFormat[cnt].NewPageBefore := cFalse;

Crpe1.SectionFormat[cnt].PrintAtBottomOfPage := cDefault;

Crpe1.SectionFormat[cnt].ResetPageNAfter := cFalse;

Crpe1.SectionFormat[cnt].Suppress := cTrue;

Crpe1.SectionFormat[cnt].SuppressBlankSection := cTrue;

Crpe1.SectionFormat[cnt].UnderlaySection := cDefault;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


BackgroundColor property

See also	Example

Applies to

SectionFormat

Declaration

property BackgroundColor: TColor;

Description

BackgroundColor specifies the color that will fill the background of a specified section on the Report.  The value can be any of the Delphi color constants, the Color value returned from Delphi's Color Dialog, or the following constants:

clUnchangedColor	= -2;

clNoColor	= $FFFFFFFF;


BackgroundColor property - See also
Related

FreeFormPlacement

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


BackgroundColor property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the BackgroundColor for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

Crpe1.SectionFormat[cnt].BackgroundColor := clRed;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


FreeFormPlacement property

See also	Example

Applies to

SectionFormat

Declaration

property FreeFormPlacement: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

FreeFormPlacement determines if objects in a specified Section can be placed anywhere, or whether they snap to the page grid.


FreeFormPlacement property - See also
Related

BackgroundColor

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


FreeFormPlacement property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets FreeFormPlacement for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

Crpe1.SectionFormat[cnt].FreeFormPlacement := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Suppress property

See also	Example

Applies to

SectionFormat

Declaration

property Suppress: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

Suppress determines if a Section will appear or not when the Report is run.  A Section which is suppressed can not be drilled down into.  To have a section hidden, but still allow drill-down, use the Hide property of the AreaFormat object.


Suppress property - See also
Related

BackgroundColor

FreeFormPlacement

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Suppress property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the Suppress option for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

Crpe1.SectionFormat[cnt].Suppress := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Item property

See also	Example

Applies to

SectionFormat

Declaration

property Item[const nIndex: integer]: TCrpeSectionFormat;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the SectionFormat object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  SectionFormat[2] is the same as SectionFormat.Item[2].

•	Item returns a reference to the SectionFormat object, so the SectionFormat properties can be used right after the subscript: SectionFormat[2].BackgroundColor := clRed;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

{Set SectionFormat to the 3rd section}

Crpe1.SectionFormat.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

{Set SectionFormat to the 3rd section}

Crpe1.SectionFormat[2];


ItemIndex property

See also	Example

Applies to

SectionFormat

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current SectionFormat item number, or set the SectionFormat object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (SectionFormat[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the SectionFormat object is pointing to the first SectionFormat item:

if Crpe1.SectionFormat.ItemIndex <> 0 then

  Crpe1.SectionFormat[0];


KeepTogether property

See also	Example

Applies to

SectionFormat

Declaration

property KeepTogether: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

KeepTogether determines whether a Section which is printing fields from the same Record will be split on a Page Break or not.  For example, if a Details section has fields placed on 4 horizontal lines, setting KeepTogether to cTrue will ensure that those fields will not be split when a Page Break occurs, by moving them all to the new page.

Note

The SectionFormat KeepTogether property is not the same as Crystal Reports' KeepGroupTogether option, which keeps a Group from splitting on a Page Break, and which is available via the KeepTogether property of the GroupOptions object.


KeepTogether property - See also
Related

BackgroundColor

FreeFormPlacement

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


KeepTogether property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the KeepTogether option for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

Crpe1.SectionFormat[cnt].KeepTogether := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


NewPageAfter property

See also	Example

Applies to

SectionFormat

Declaration

property NewPageAfter: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

NewPageAfter determines if a Page Break will occur after the specified Section.


NewPageAfter property - See also
Related

BackgroundColor

FreeFormPlacement

KeepTogether

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NewPageAfter property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the NewPageAfter option for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

Crpe1.SectionFormat[cnt].NewPageAfter := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


NewPageBefore property

See also	Example

Applies to

SectionFormat

Declaration

property NewPageBefore: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

NewPageBefore determines if a Page Break will occur before the specified Section.


NewPageBefore property - See also
Related

BackgroundColor

FreeFormPlacement

KeepTogether

NewPageAfter

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NewPageBefore property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the NewPageBefore option for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

Crpe1.SectionFormat[cnt].NewPageBefore := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


PrintAtBottomOfPage property

See also	Example

Applies to

SectionFormat

Declaration

property PrintAtBottomOfPage: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

PrintAtBottomOfPage determines if the specified Section will appear at the bottom of the page when the Report is run.


PrintAtBottomOfPage property - See also
Related

BackgroundColor

FreeFormPlacement

KeepTogether

NewPageAfter

NewPageBefore

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintAtBottomOfPage property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the PrintAtBottomOfPage option for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

Crpe1.SectionFormat[cnt].PrintAtBottomOfPage := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


ResetPageNAfter property

See also	Example

Applies to

SectionFormat

Declaration

property ResetPageNAfter: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

ResetPageNAfter determines if the Page Number will be reset back to 1 after the specified Section.


ResetPageNAfter property - See also
Related

BackgroundColor

FreeFormPlacement

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ResetPageNAfter property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the ResetPageNAfter option for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

Crpe1.SectionFormat[cnt].ResetPageNAfter := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Section property

See also	Example

Applies to

SectionFormat

Declaration

property Section: TCrSectionFormatSection;

Type

TCrSectionFormatSection = string;

Description

The Section property contains the Section name of the item that the SectionFormat object is currently pointed to.  It's primary use is as a look-up property to point the SectionFormat object to the item with the Section specified.  The default array property, Item, however, provides an easier way to navigate through the object.

If the Retrieve method is used, the Section name of each SectionFormat item is automatically filled when the SectionFormat information is retrieved.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections.  Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.


Section property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Section property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets various options for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

begin

Crpe1.SectionFormat[cnt].BackgroundColor := clRed;

Crpe1.SectionFormat[cnt].FreeFormPlacement := cTrue;

Crpe1.SectionFormat[cnt].KeepTogether := cTrue;

Crpe1.SectionFormat[cnt].NewPageAfter := cFalse;

Crpe1.SectionFormat[cnt].NewPageBefore := cFalse;

Crpe1.SectionFormat[cnt].PrintAtBottomOfPage := cDefault;

Crpe1.SectionFormat[cnt].ResetPageNAfter := cFalse;

Crpe1.SectionFormat[cnt].Suppress := cTrue;

Crpe1.SectionFormat[cnt].SuppressBlankSection := cTrue;

Crpe1.SectionFormat[cnt].UnderlaySection := cDefault;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


SuppressBlankSection property

See also	Example

Applies to

SectionFormat

Declaration

property SuppressBlankSection: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

SuppressBlankSection determines whether the specified Section will be suppressed if it is blank.  A Section must be completely empty before it will be suppressed.  Fields that have empty strings or nulls will be counted as empty, but if they have even so little as a space for a value, they will not be counted as empty.


SuppressBlankSection property - See also
Related

BackgroundColor

FreeFormPlacement

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SuppressBlankSection property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the SuppressBlankSection option for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

Crpe1.SectionFormat[cnt].SuppressBlankSection := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


UnderlaySection property

See also	Example

Applies to

SectionFormat

Declaration

property UnderlaySection: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

UnderlaySection determines if the specified Section will print underneath the following Section, like a transparency.


UnderlaySection property - See also
Related

BackgroundColor

FreeFormPlacement

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


UnderlaySection property - Example
Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the UnderlaySection option for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

Crpe1.SectionFormat[cnt].UnderlaySection := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Create method

See also

Applies to

SectionFormat

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the SectionFormat object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

SectionFormat

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

SectionFormat

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the SectionFormat object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then

begin

Crpe1.SectionFormat[cnt].BackgroundColor := clRed;

Crpe1.SectionFormat[cnt].FreeFormPlacement := cTrue;

Crpe1.SectionFormat[cnt].KeepTogether := cTrue;

Crpe1.SectionFormat[cnt].ResetPageNAfter := cFalse;

Crpe1.SectionFormat[cnt].Suppress := cTrue;

Crpe1.SectionFormat[cnt].SuppressBlankSection := cTrue;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Retrieve method

See also	Example

Applies to

SectionFormat

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SectionFormat information from the Report and stores it in the SectionFormat object.  If no SectionFormat information was found, the call returns False.  Be aware that calling Retrieve will first cause the SectionFormat object to be cleared, so any current information stored in it will be removed.

Note

Since the SectionFormat object also applies to Subreports, the Retrieve method will obtain the SectionFormat for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the SectionFormat information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate SectionFormat information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.SectionFormat.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

SectionFormat

Declaration

function Send: boolean;

Description

The Send method sends the SectionFormat values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the SectionFormat settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SectionFormat.Send;


Add method

See also	Example

Applies to

SectionFormat

Declaration

function Add(SectionName: TCrSectionFormatSection): integer;

Type

TCrSectionFormatSection = string;

Description

The Add method adds an item to the SectionFormat object and sets the internal index to that item.  It requires a Section name as a parameter, which should be a name corresponding to a Section in the Report.  Sections are named using the Short Section Name convention used in Crystal Reports (see About Section Names for more information).  If the Add method is used, the steps to using SectionFormat are:

1. Add an item to the SectionFormat object (you must specify the Section name).

2. Fill the item's properties (NewPageAfter, SuppressBlankSection, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Section names are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the SectionFormat object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.SectionFormat.Add('Da');

Crpe1.SectionFormat.BackgroundColor := clRed;

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

SectionFormat

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the SectionFormat object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the SectionFormat object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the SectionFormat of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the SectionFormat properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.SectionFormat.Clear;

This code clears the SectionFormat properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.SectionFormat.Clear;

end;


Delete method

See also	Example

Applies to

SectionFormat

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the SectionFormat object.  The "nIndex" parameter represents the number of the item in the SectionFormat object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the SectionFormat object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.SectionFormat.Add('Da');

Crpe1.SectionFormat.BackgroundColor := clRed;

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SectionFormat.Delete(0);


SectionAsCode property

See also	Example

Applies to

SectionFormat

Declaration

property SectionAsCode: smallint

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a "For loop", for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The SectionAsCode property can be used to apply formatting to specific sections based on mathematical calculations or comparisons.  The following code checks each section to see if it is a "b" section, such as RHb, PHb, Db, etc, and if it is, the background color is changed to red:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormat.Retrieve;

for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

begin

  if (Crpe1.SectionFormat[cnt].SectionAsCode mod 1000 = 25) then

    Crpe1.SectionFormat[cnt].BackgroundColor := clRed;

end;

Crpe1.Execute;

The logic behind the math expression is based on the fact that each sub-section increments the Section Code number by 25 (from 0 to 975 are the possible numbers).  So, since 3000 is the general Section Code start number for a Group Header, and is therefore the number to represent GroupHeader 1a, 3025 represents GroupHeader 1b, 3050 represents GroupHeader 1c, etc.  Therefore, in order to find the "b" sections we must divide by 1000, and if the remainder is 25, it is a "b" section.  This also works for all the other sections that do not have Group options, such as Details, ReportHeader, etc. since dividing by 25 will also return no remainder if the Section Code number is evenly divisible by 1000.


SectionType method

See also	Example

Applies to

SectionFormat

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1ac, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier.  See the Example for an illustration.


SectionType method - See also
Related

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionType method - Example
Example

The following example uses the SectionType method to apply conditional formatting to Sections.  In this case, the formatting is only to apply to Group Header sections:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SectionFormat.Retrieve;

  for cnt := 0 to (Crpe1.SectionFormat.Count - 1) do

  begin

    {if the SectionType is Group Header, apply the change}

    if (Crpe1.SectionFormat[cnt].SectionType = 'GH') then

      Crpe1.SectionFormat[cnt].BackgroundColor := clRed;

  end;

end;


CopyFrom method

See also	Example

Applies to

SectionFormat

Declaration

procedure CopyFrom(Source: TCrpeSectionFormat);

Description

The CopyFrom method copies the SectionFormat property values from another TCrpeSectionFormat object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the SectionFormat property values to a temporary TCrpeSectionFormat object:

var

tempSectionFormat : TCrpeSectionFormat;

begin

tempSectionFormat := TCrpeSectionFormat.Create;

tempSectionFormat.CopyFrom(Crpe1.SectionFormat);

{...later, when finished with the temp object...}

tempSectionFormat.Free;

end;


AreaFormat

See also	Properties & Methods	Example

Declaration

property AreaFormat: TCrpeAreaFormat;

Type

TCrpeAreaFormat = class(TPersistent)

Description

AreaFormat controls how the area sections of a Report behave.  It is similar to SectionFormat, except that SectionFormat applies to individual sub-sections, whereas AreaFormat works on all of the sections of the same type at once.

The Section naming format has been adopted from the Crystal Reports "short" section naming convention, so RH means ReportHeader, GH3 means GroupHeader 3, etc.  See "About Section Names" for more information.

•	If the Retrieve method is used to get the Area information from the Report, the AreaFormat object will be automatically populated with valid area section names, which appear in the Section property.

•	If the manual Add method is used instead, the programmer will have to specify which Section to add to the object.

•	The Count, Item, and ItemIndex properties can be used to navigate through the different Section items in the AreaFormat object.

•	The Hide property will cause a Section to be hidden, although drill-down is still possible.  To suppress a Section so that it is not processed, and is not available for drill-down, use the Suppress property.

•	The KeepTogether property will prevent a Section from splitting on a page break.  This is not the same as Keep Group Together, which is available via the KeepTogether property of the GroupOptions object.

•	The NewPageAfter and NewPageBefore properties determine if a page break will happen after or before a particular Section.

•	The PrintAtBottomOfPage property will cause the Section to appear at the bottom of the page.

•	The ResetPageNAfter property will cause the Page Number to be reset after a particular Section.

•	The SectionAsCode property offers the ability to treat the Section name as a Section Code Number, which can be useful for doing mathematical expressions to filter out certain sections.

•	The SectionType method returns just the first characters of the Section name, so for GH1 (Group Header 1), the SectionType would be GH (Group Header).

Limitations

For Report Header (RH) areas, the NewPageBefore property does not apply.

For Report Footer (RF) areas, the NewPageAfter property does not apply.

For Page Header (PH) and Page Footer (PF) areas, the following options do not apply (setting them will have no effect on the Report):

Hide

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage


AreaFormat - See also
Related

AreaFormatFormulas

SectionFormat

SectionFormatFormulas

SectionFont

SectionHeight

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AreaFormat - Properties & Methods
AreaFormat:

Properties & Methods

AreaFormat	TCrpe Component

Properties

Hide

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

Key

Section

SectionAsCode

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


AreaFormat - Example
Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets various options for that area:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

begin

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then

begin

Crpe1.AreaFormat[cnt].Hide := cFalse;

Crpe1.AreaFormat[cnt].KeepTogether := cTrue;

Crpe1.AreaFormat[cnt].NewPageAfter := cDefault;

Crpe1.AreaFormat[cnt].NewPageBefore := cDefault;

Crpe1.AreaFormat[cnt].PrintAtBottomOfPage := cFalse;

Crpe1.AreaFormat[cnt].ResetPageNAfter := cTrue;

Crpe1.AreaFormat[cnt].Suppress := cFalse;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;

The following example hides the Details area of a Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

Crpe1.AreaFormat.Section := 'D';

Crpe1.AreaFormat.Hide := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


Hide property

See also	Example

Applies to

AreaFormat

Declaration

property Hide: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

Hide determines if the specified Area will show or not.  A hidden section is still available for drill-down in the Preview Window (provided that the drill-down options are turned on in the WindowButtonBar object).  To suppress an Area so that it is not available for drill-down, use the Suppress property.


Hide property - See also
Related

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Hide property - Example
Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets the Hide option for that area:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

begin

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then

Crpe1.AreaFormat[cnt].Hide := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Item property

See also	Example

Applies to

AreaFormat

Declaration

property Item[const nIndex: integer]: TCrpeAreaFormat;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the AreaFormat object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  AreaFormat[2] is the same as AreaFormat.Item[2].

•	Item returns a reference to the AreaFormat object, so the AreaFormat properties can be used right after the subscript: AreaFormat[2].Hide := True;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

{Set AreaFormat to the 3rd area}

Crpe1.AreaFormat.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

{Set AreaFormat to the 3rd area}

Crpe1.AreaFormat[2];


ItemIndex property

See also	Example

Applies to

AreaFormat

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current AreaFormat item number, or set the AreaFormat object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (AreaFormat[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the AreaFormat object is pointing to the first AreaFormat item:

if Crpe1.AreaFormat.ItemIndex <> 0 then

  Crpe1.AreaFormat[0];


KeepTogether property

See also	Example

Applies to

AreaFormat

Declaration

property KeepTogether: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

KeepTogether determines whether an Area which is printing fields from the same Record will be split on a Page Break or not.  For example, if a Details area has fields placed on 4 horizontal lines, setting KeepTogether to cTrue will ensure that those fields will not be split when a Page Break occurs, by moving them all to the new page.

Note

The AreaFormat KeepTogether property is not the same as Crystal Reports' KeepGroupTogether option, which keeps a Group from splitting on a Page Break, and which is available via the KeepTogether property of the GroupOptions object.


KeepTogether property - See also
Related

Hide

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


KeepTogether property - Example
Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets the KeepTogether option for that area:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

begin

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then

Crpe1.AreaFormat[cnt].KeepTogether := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


NewPageAfter property

See also	Example

Applies to

AreaFormat

Declaration

property NewPageAfter: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

NewPageAfter determines if a Page Break will occur after the specified Area.


NewPageAfter property - See also
Related

Hide

KeepTogether

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NewPageAfter property - Example
Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets the NewPageAfter option for that area:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

begin

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then

Crpe1.AreaFormat[cnt].NewPageAfter := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


NewPageBefore property

See also	Example

Applies to

AreaFormat

Declaration

property NewPageBefore: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

NewPageBefore determines if a Page Break will occur before the specified Area.


NewPageBefore property - See also
Related

Hide

KeepTogether

NewPageAfter

PrintAtBottomOfPage

ResetPageNAfter

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NewPageBefore property - Example
Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets the NewPageBefore option for that area:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

begin

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then

Crpe1.AreaFormat[cnt].NewPageBefore := cDefault;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


PrintAtBottomOfPage property

See also	Example

Applies to

AreaFormat

Declaration

property PrintAtBottomOfPage: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

PrintAtBottomOfPage determines if the specified Area will appear at the bottom of the page when the Report is run.


PrintAtBottomOfPage property - See also
Related

Hide

KeepTogether

NewPageAfter

NewPageBefore

ResetPageNAfter

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintAtBottomOfPage property - Example
Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets the PrintAtBottomOfPage option for that area:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

begin

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then

Crpe1.AreaFormat[cnt].PrintAtBottomOfPage := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


ResetPageNAfter property

See also	Example

Applies to

AreaFormat

Declaration

property ResetPageNAfter: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

ResetPageNAfter determines if the Page Number will be reset back to 1 after the specified Area.


ResetPageNAfter property - See also
Related

Hide

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ResetPageNAfter property - Example
Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets the ResetPageNAfter option for that area:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

begin

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then

Crpe1.AreaFormat[cnt].ResetPageNAfter := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Section property

See also	Example

Applies to

AreaFormat

Declaration

property Section: TCrAreaFormatSection;

Types

TCrAreaFormatSection = string;

Description

The Section property contains the Section name of the item that the AreaFormat object is currently pointed to.  It's primary use is as a look-up property to point the AreaFormat object to the item with the Section specified.  The default array property, Item, however, provides an easier way to navigate through the object.

If the Retrieve method is used, the Section name of each AreaFormat item is automatically filled when the AreaFormat information is retrieved.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.

Note

Whereas objects such as SectionFormat and SectionFormatFormulas work on specific individual sub-sections, such as Details "a", Details "b", etc., AreaFormat and AreaFormatFormulas work on certain areas, for example, Details area.  The options set in these objects affect all the sub-sections of that Area as a unit.


Section property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Section property - Example
Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets various options for that area:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

begin

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then

begin

Crpe1.AreaFormat[cnt].Hide := cFalse;

Crpe1.AreaFormat[cnt].KeepTogether := cTrue;

Crpe1.AreaFormat[cnt].NewPageAfter := cDefault;

Crpe1.AreaFormat[cnt].NewPageBefore := cDefault;

Crpe1.AreaFormat[cnt].PrintAtBottomOfPage := cFalse;

Crpe1.AreaFormat[cnt].ResetPageNAfter := cTrue;

Crpe1.AreaFormat[cnt].Suppress := cFalse;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Suppress property

See also	Example

Applies to

AreaFormat

Declaration

property Suppress: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

Suppress determines if the specified Area will show or not.  A suppressed section is not available for drill-down in the Preview Window (the drill-down options are specified in the WindowButtonBar object).  To hide an Area so that it is still available for drill-down, use the Hide property.


Suppress property - See also
Related

Hide

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Suppress property - Example
Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets the Suppress option for that area:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

begin

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then

Crpe1.AreaFormat[cnt].Suppress := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Create method

See also

Applies to

AreaFormat

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the AreaFormat object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

AreaFormat

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

AreaFormat

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the AreaFormat object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.AreaFormat.Retrieve;

  for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

    Crpe1.AreaFormat[cnt].KeepTogether := cTrue;

end;


Retrieve method

See also	Example

Applies to

AreaFormat

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the AreaFormat information from the Report and stores it in the AreaFormat object.  If no AreaFormat information was found, the call returns False.  Be aware that calling Retrieve will first cause the AreaFormat object to be cleared, so any current information stored in it will be removed.

Note

Since the AreaFormat object also applies to Subreports, the Retrieve method will obtain the AreaFormat for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the AreaFormat information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate AreaFormat information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.AreaFormat.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

AreaFormat

Declaration

function Send: boolean;

Description

The Send method sends the AreaFormat values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the AreaFormat settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.AreaFormat.Send;


Add method

See also	Example

Applies to

AreaFormat

Declaration

function Add(SectionName: TCrAreaFormatSection): integer;

Type

TCrAreaFormatSection = string;

Description

The Add method adds an item to the AreaFormat object and sets the internal index to that item.  It requires a Section name as a parameter, which should be a name corresponding to a Section in the Report.  Sections are named using the Short Section Name convention used in Crystal Reports (see About Section Names for more information).  If the Add method is used, the steps to using AreaFormat are:

1. Add an item to the AreaFormat object (you must specify the Section name).

2. Fill the item's properties (KeepTogether, Suppress, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Section names are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the AreaFormat object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.AreaFormat.Add('D');

Crpe1.AreaFormat.KeepTogether := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

AreaFormat

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the AreaFormat object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the AreaFormat object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the AreaFormat of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the AreaFormat properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.AreaFormat.Clear;

This code clears the AreaFormat properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.AreaFormat.Clear;

end;


Delete method

See also	Example

Applies to

AreaFormat

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the AreaFormat object.  The "nIndex" parameter represents the number of the item in the AreaFormat object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the AreaFormat object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.AreaFormat.Add('D');

Crpe1.AreaFormat.KeepTogether := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.AreaFormat.Delete(0);


SectionAsCode property

See also	Example

Applies to

AreaFormat

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The SectionAsCode property can be used to apply formatting to specific sections based on mathematical calculations or comparisons.  The following code checks each section to see if it is a Group section greater than 1, such as GH2, GH3, etc, and if it is, the Area is suppressed:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

begin

  if (Crpe1.AreaFormat[cnt].SectionAsCode mod 1000 > 0) then

    Crpe1.AreaFormat[cnt].Suppress := cTrue;

end;

Crpe1.Execute;

The logic behind the math expression is based on the fact that each group-area increments the Section Code number by 1 (from 0 to 24 are the possible numbers).  So, since 3000 is the general Section Code start number for a Group Header, and is therefore the number to represent GroupHeader 1, 3001 represents GroupHeader 2, 3002 represents GroupHeader 3, etc.  Dividing by 1000 will only give a remainder for those Groups that are greater than 1.


SectionType method

See also	Example

Applies to

AreaFormat

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier.  See the Example for an illustration.

Note

Since AreaFormat already works on an "area" rather than "section" basis, this method is of limited use.  It can be used with the Group areas, however, since it will ignore Group numbers, and in this way, formatting can be applied to all the Groups.


SectionType method - See also
Related

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionType method - Example
Example

The following example uses the SectionType method to apply conditional formatting.  The formatting is to apply to all Group areas, so the SectionType method can be used in an expression to apply the changes:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.AreaFormat.Retrieve;

  for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do

  begin

    {if the SectionType is Group Header, apply the change}

    if (Crpe1.AreaFormat[cnt].SectionType = 'GH') then

      Crpe1.AreaFormat[cnt].Hide := cTrue;

  end;

end;


CopyFrom method

See also	Example

Applies to

AreaFormat

Declaration

procedure CopyFrom(Source: TCrpeAreaFormat);

Description

The CopyFrom method copies the AreaFormat property values from another TCrpeAreaFormat object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the AreaFormat property values to a temporary TCrpeAreaFormat object:

var

tempAreaFormat : TCrpeAreaFormat;

begin

tempAreaFormat := TCrpeAreaFormat.Create;

tempAreaFormat.CopyFrom(Crpe1.Version);

{...later, when finished with the temp object...}

tempAreaFormat.Free;

end;


SectionFont

See also	Properties & Methods	Example

Declaration

property SectionFont: TCrpeSectionFont;

Type

TCrpeSectionFont = class(TPersistent)

Description

The SectionFont object contains the properties that can be used to change the Font used in a Report section.  Font styles can not be changed on a field by field basis, but only for a complete section at a time, although you can specify whether the changes should affect database fields, text fields, or both.

The Section naming format has been adopted from the Crystal Reports "short" section naming convention, so RHa means ReportHeader "a", GH3b means GroupHeader 3b, etc.  See "About Section Names" for more information.

•	The Retrieve method can be used to fill the SectionFont object with the Report sections.  It is not actually possible to retrieve Font information, so the Retrieve method simply gathers the Section names, and sets the other SectionFont properties to default.

•	The Count method yields the number of SectionFont items contained in the SectionFont object.

•	The default array property, Item, or the ItemIndex property can be used to navigate through the sections (as well as the Section property).

•	The Font name can be set using the Name property, which is a property of the Delphi type: TFontName.

•	The size of the Font is controlled by the Size property.

•	The three attributes Italic, StrikeThrough, and Underlined can be set through those properties.

•	Bold is controlled by the Weight property.

•	The Pitch property determines if the Font spacing is fixed or variable.

•	The CharSet property determines which character set is used for the upper ASCII characters.

•	The Family property specifies the Font family.

•	The Scope property specifies whether the Font changes are to affect database fields, or text fields, or both.

•	The SectionAsCode property offers the ability to treat the Section name as a Section Code Number, which can be useful for doing mathematical expressions to filter out certain sections.

•	The SectionType method returns just the first characters of the Section name, so for GH1 (Group Header 1), the SectionType would be GH (Group Header).


SectionFont - See also
Related

AreaFormat

AreaFormatFormulas

SectionFormat

SectionFormatFormulas

SectionHeight

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionFont - Properties & Methods
SectionFont:

Properties & Methods

SectionFont	TCrpe Component

Properties

Font Attributes

CharSet

Family

Italic

Name

Pitch

Size

StrikeThrough

Underlined

Weight

Affected Text

Scope

Key

Section

SectionAsCode

Navigation

Item

ItemIndex

Method

Clear

CopyFrom

Count

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


SectionFont - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets various options for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

Crpe1.SectionFont[cnt].Pitch := fpDefault;

Crpe1.SectionFont[cnt].Scope := Both;

Crpe1.SectionFont[cnt].CharSet := fcDefault;

Crpe1.SectionFont[cnt].Family := ffDefault;

Crpe1.SectionFont[cnt].Italic := cTrue;

Crpe1.SectionFont[cnt].StrikeThrough := cFalse;

Crpe1.SectionFont[cnt].Underlined := cFalse;

Crpe1.SectionFont[cnt].Weight := fwBold;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;

The following sample retrieves the SectionFont sections from the Report, and then changes the Text fields in the Group Header to Times New Roman font, 12 point size:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

Crpe1.SectionFont.Section := 'GH1';

Crpe1.SectionFont.Name := 'Times New Roman';

Crpe1.SectionFont.Size := 12;

Crpe1.SectionFont.Scope := Text;

Crpe1.Execute;


CharSet property

See also	Example

Applies to

SectionFont

Declaration

property CharSet: TCrFontCharSet;

Type

TCrFontCharSet = (fcAnsi, fcDefault, fcSymbol, fcShiftJis, fcHangeul, fcChineseBig5, fcOEM);

Description

CharSet determines the Character Set that is used for the Font in the specified Section.  Use fcDefault for no change.


CharSet property - See also
Related

Family

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CharSet property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size, and CharSet for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

Crpe1.SectionFont[cnt].CharSet := fcDefault;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Family property

See also	Example

Applies to

SectionFont

Declaration

property Family: TCrFontFamily;

Type

TCrFontFamily = (ffDefault, ffRoman, ffSwiss, ffModern, ffScript, ffDecorative);

Description

The Family property specifies the Font Family that is used for the Font in the specified Section.  Use ffDefault for no change.


Family property - See also
Related

CharSet

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Family property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size, and Family for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

Crpe1.SectionFont[cnt].Family := ffDefault;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Italic property

See also	Example

Applies to

SectionFont

Declaration

property Italic: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The Italic property determines whether the Font should be italicized.  Use cDefault for no change.


Italic property - See also
Related

StrikeThrough

Underlined

Weight

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Italic property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size, and Italic properties for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

Crpe1.SectionFont[cnt].Italic := cTrue;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Item property

See also	Example

Applies to

SectionFont

Declaration

property Item[const nIndex: integer]: TCrpeSectionFont;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the SectionFont object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  SectionFont[2] is the same as SectionFont.Item[2].

•	Item returns a reference to the SectionFont object, so the SectionFont properties can be used right after the subscript: SectionFont[2].Name := 'Times New Roman';


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

{Set SectionFont object to the 3rd section}

Crpe1.SectionFont.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

{Set SectionFont object to the 3rd section}

Crpe1.SectionFont[2];


ItemIndex property

See also	Example

Applies to

SectionFont

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current SectionFont item number, or set the SectionFont object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (SectionFont[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the SectionFont object is pointing to the first SectionFont item:

if Crpe1.SectionFont.ItemIndex <> 0 then

  Crpe1.SectionFont[0];


Name property

See also	Example

Applies to

SectionFont

Declaration

property Name: TFontName;

Description

Name specifies the Font Name to be used for the specified Section.  The property uses Delphi's TFontName type, which makes a list of installed fonts available on the Object Inspector (or if the property is double-clicked, the Font Dialog will appear).


Name property - See also
Related

Size

Scope

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Name property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name and Size for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Pitch property

See also	Example

Applies to

SectionFont

Declaration

property Pitch: TFontPitch;

Type

TFontPitch = (fpDefault, fpVariable, fpFixed);

Description

Pitch determines whether the Font character spacing will be Fixed or Variable.

•	With Fixed Pitch, each character occupies the same width, as on a typewriter.

•	With Variable Pitch, characters only occupy as much space as is required, so an "i" takes up less space than a "w".

•	Fixed Pitch is commonly used with numbers, so that the columns line up properly.


Pitch property - See also
Related

CharSet

Family

Name

Size

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Pitch property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size and Pitch for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

Crpe1.SectionFont[cnt].Pitch := fpVariable;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Scope property

See also	Example

Applies to

SectionFont

Declaration

property Scope: TCrFontScope;

Type

TCrFontScope = (Fields, Text, Both);

Description

The Scope property determines what type of Fields the Font changes will apply to:  Database Fields, Text Fields, or both.


Scope property - See also
Related

Name

Size

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Scope property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size, and Scope for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

Crpe1.SectionFont[cnt].Scope := Both;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Section property

See also	Example

Applies to

SectionFont

Declaration

property Section: TCrSectionFontSection;

Types

TCrSectionFontSection = string;

Description

The Section property contains the Section name of the item that the SectionFont object is currently pointed to.  It's primary use is as a look-up property to point the SectionFont object to the item with the Section specified.  The default array property, Item, however, provides an easier way to navigate through the object.

If the Retrieve method is used, the Section name of each SectionFont item is automatically filled when the SectionFont information is retrieved.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections.  Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.


Section property - See also
Related

SectionAsCode

SectionType

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Section property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets various options for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

Crpe1.SectionFont[cnt].Scope := Both;

Crpe1.SectionFont[cnt].Italic := cTrue;

Crpe1.SectionFont[cnt].Weight := fwBold;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Size property

See also	Example

Applies to

SectionFont

Declaration

property Size: smallint;

Description

The Size property determines how large or small the Font will be.  The scale is in points.


Size property - See also
Related

Name

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Size property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name and Size for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


StrikeThrough property

See also	Example

Applies to

SectionFont

Declaration

property StrikeThrough: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The StrikeThrough property determines whether the Font should have strike through lines in it.  Use cDefault for no change.


StrikeThrough property - See also
Related

Italic

Underlined

Weight

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


StrikeThrough property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size, and StrikeThrough properties for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

Crpe1.SectionFont[cnt].StrikeThrough := cTrue;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Underlined property

See also	Example

Applies to

SectionFont

Declaration

property Underlined: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The Underlined property determines whether the Font should be underlined.  Use cDefault for no change.


Underlined property - See also
Related

Italic

StrikeThrough

Weight

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Underlined property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size, and Underlined properties for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

Crpe1.SectionFont[cnt].Underlined := cTrue;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Weight property

See also	Example

Applies to

SectionFont

Declaration

property Weight: TCrFontWeight;

Type

TCrFontWeight = (fwDefault, fwThin, fwExtraLight, fwLight, fwNormal,     fwMedium, fwSemiBold, fwBold, fwExtraBold, fwHeavy);

Description

The Weight property determines how heavy (thick) or light (thin) the Font will appear.  Use fwDefault for no change.


Weight property - See also
Related

Italic

StrikeThrough

Underlined

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Weight property - Example
Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size, and Weight properties for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

Crpe1.SectionFont[cnt].Size := 10;

Crpe1.SectionFont[cnt].Weight := fwBold;

end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Create method

See also

Applies to

SectionFont

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the SectionFont object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

SectionFont

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

SectionFont

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the SectionFont object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SectionFont.Retrieve;

  for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

    Crpe1.SectionFont[cnt].Name := 'Times New Roman';

end;


Retrieve method

See also	Example

Applies to

SectionFont

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SectionFont information from the Report and stores it in the SectionFont object.  If no SectionFont information was found, the call returns False.  Be aware that calling Retrieve will first cause the SectionFont object to be cleared, so any current information stored in it will be removed.

Note

•	There is currently no way to obtain Font information from the Print Engine at runtime so Retrieve simply adds an item to the SectionFont object for each Report Section it finds, obtains the current Section Code for the Section property, and sets the other properties to default values.

•	Since the SectionFont object also applies to Subreports, the Retrieve method will obtain the SectionFont for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the SectionFont information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate SectionFont information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.SectionFont.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

SectionFont

Declaration

function Send: boolean;

Description

The Send method sends the SectionFont values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the SectionFont settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SectionFont.Send;


Add method

See also	Example

Applies to

SectionFont

Declaration

function Add(SectionName: TCrSectionFontSection): integer;

Type

TCrSectionFontSection = string;

Description

The Add method adds an item to the SectionFont object and sets the internal index to that item.  It requires a Section name as a parameter, which should be a name corresponding to a Section in the Report.  Sections are named using the Short Section Name convention used in Crystal Reports (see About Section Names for more information).  If the Add method is used, the steps to using SectionFont are:

1. Add an item to the SectionFont object (you must specify the Section name).

2. Fill the item's properties (Name, Size, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Section names are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the SectionFont object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.SectionFont.Add('Da');

Crpe1.SectionFont.Name := 'Times New Roman';

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

SectionFont

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the SectionFont object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the SectionFont object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the SectionFont of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the SectionFont properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.SectionFont.Clear;

This code clears the SectionFont properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.SectionFont.Clear;

end;


Delete method

See also	Example

Applies to

SectionFont

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the SectionFont object.  The "nIndex" parameter represents the number of the item in the SectionFont object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the SectionFont object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.SectionFont.Add('Da');

Crpe1.SectionFont.Name := 'Times New Roman';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SectionFont.Delete(0);


SectionAsCode property

See also	Example

Applies to

SectionFont

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

Section

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The SectionAsCode property can be used to apply formatting to specific sections based on mathematical calculations or comparisons.  The following code checks each section to see if it is a "b" section, such as RHb, PHb, Db, etc, and if it is, the Font Size is changed to 10 point:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

begin

  if (Crpe1.SectionFont[cnt].SectionAsCode mod 1000 = 25) then

    Crpe1.SectionFont[cnt].Size := 10;

end;

Crpe1.Execute;

The logic behind the math expression is based on the fact that each sub-section increments the Section Code number by 25 (from 0 to 975 are the possible numbers).  So, since 3000 is the general Section Code start number for a Group Header, and is therefore the number to represent GroupHeader 1a, 3025 represents GroupHeader 1b, 3050 represents GroupHeader 1c, etc.  Therefore, in order to find the "b" sections we must divide by 1000, and if the remainder is 25, it is a "b" section.  This also works for all the other sections that do not have Group options, such as Details, ReportHeader, etc. since dividing by 25 will also return no remainder if the Section Code number is evenly divisible by 1000.


SectionType method

See also	Example

Applies to

SectionFont

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1ac, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier.


SectionType method - See also
Related

Section

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionType method - Example
Example

The following example uses the SectionType method to apply conditional formatting.  In this case, we want to change the Font style for the Group Header sections only:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SectionFont.Retrieve;

  for cnt := 0 to (Crpe1.SectionFont.Count - 1) do

  begin

    {if the SectionType is Group Header, apply the change}

    if (Crpe1.SectionFont[cnt].SectionType = 'GH') then

      Crpe1.SectionFont[cnt].Name := 'Times New Roman';

  end;

end;


CopyFrom method

See also	Example

Applies to

SectionFont

Declaration

procedure CopyFrom(Source: TCrpeSectionFont);

Description

The CopyFrom method copies the SectionFont property values from another TCrpeSectionFont object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the SectionFont property values to a temporary TCrpeSectionFont object:

var

tempSectionFont : TCrpeSectionFont;

begin

tempSectionFont := TCrpeSectionFont.Create;

tempSectionFont.CopyFrom(Crpe1.SectionFont);

{...later, when finished with the temp object...}

tempSectionFont.Free;

end;


SectionHeight

See also	Properties & Methods	Example

Declaration

property SectionHeight: TCrpeSectionHeight;

Type

TCrpeSectionHeight = class(TPersistent)

Description

SectionHeight controls the minimum height of each section in the Report.  It can be used to expand the size of a Section.  It's main properties and methods are as follows:

•	The Retrieve method can be used to obtain the SectionHeight information from a Report.

•	The Height property specifies the minimum Section height.  The height is in twips, but these can be converted to inches by the following formula:  Inches := Twips / 1440;

•	As on most of the other Crystal component objects, the default array property, Item, or the ItemIndex property, can be used to navigate the object through the Sections.

•	The SectionAsCode property offers the ability to treat the Section name as a Section Code Number, which can be useful for doing mathematical expressions to filter out certain sections.

•	The SectionType method returns just the first characters of the Section name, so for GH1 (Group Header 1), the SectionType would be GH (Group Header).

The Section naming format has been adopted from the Crystal Reports "short" section naming convention, so RHa means ReportHeader a, GH3b means GroupHeader 3b, etc.  See "About Section Names" for more information.

Note

If a SectionHeight value is specified which is less than the actual Section height, it will be ignored when the Report is run.  SectionHeight checks the current height of each Section, and then sends in the SectionHeight values only if they are larger than the current height of the Section.


SectionHeight - See also
Related

AreaFormat

AreaFormatFormulas

SectionFormat

SectionFormatFormulas

SectionFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionHeight - Properties & Methods
SectionHeight:

Properties & Methods

SectionHeight	TCrpe Component

Properties

Height

Key

Section

SectionAsCode

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


SectionHeight - Example
Example

The code below retrieves the SectionHeight settings from the Report, then loops through looking for the Details "a" section, and sets the Height for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionHeight.Retrieve;

for cnt := 0 to (Crpe1.SectionHeight.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionHeight[cnt].Section = 'Da' then

Crpe1.SectionHeight[cnt].Height := 400;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;

The following example sets the Section height for the first section of the Report to 400 twips:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionHeight.Retrieve;

Crpe1.SectionHeight[0].Height := 400;

Crpe1.Output := toWindow;

Crpe1.Execute;


Height property

See also	Example

Applies to

SectionHeight

Declaration

property Height: smallint;

Description

Height determines the height of the specified Section in twips.

•	There are 1440 twips to an inch.

•	There are 20 twips to a point.

•	There are 72 points to an inch.

Conversion Formulas

Twips	:= Inches * 1440

Inches	:= Twips / 1440

Points	:= Twips / 20

Twips	:= Points * 20

Inches	:= Points / 72

Points	:= Inches * 72


Height property - See also
Related

Section

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Height property - Example
Example

The code below retrieves the SectionHeight settings from the Report, then loops through looking for the Details "a" section, and sets the Height for that Section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionHeight.Retrieve;

for cnt := 0 to (Crpe1.SectionHeight.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionHeight[cnt].Section = 'Da' then

Crpe1.SectionHeight[cnt].Height := 400;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Item property

See also	Example

Applies to

SectionHeight

Declaration

property Item[const nIndex: integer]: TCrpeSectionHeight;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the SectionHeight object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  SectionHeight[2] is the same as SectionHeight.Item[2].

•	Item returns a reference to the SectionHeight object, so the SectionHeight properties can be used right after the subscript: SectionHeight[2].Height := 300;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionHeight.Retrieve;

{Set SectionHeight to the 3rd section}

Crpe1.SectionHeight.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionHeight.Retrieve;

{Set SectionHeight to the 3rd section}

Crpe1.SectionHeight[2];


ItemIndex property

See also	Example

Applies to

SectionHeight

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current SectionHeight item number, or set the SectionHeight object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (SectionHeight[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the SectionHeight object is pointing to the first SectionHeight item:

if Crpe1.SectionHeight.ItemIndex <> 0 then

  Crpe1.SectionHeight[0];


Section property

See also	Example

Applies to

SectionHeight

Declaration

property Section: TCrSectionHeightSection;

Types

TCrSectionHeightSection = string;

Description

The Section property contains the Section name of the item that the SectionHeight object is currently pointed to.  It's primary use is as a look-up property to point the SectionHeight object to the item with the Section specified.  The default array property, Item, however, provides an easier way to navigate through the object.

If the Retrieve method is used, the Section name of each SectionHeight item is automatically filled when the SectionHeight information is retrieved.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections.  Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.


Section property - See also
Related

SectionAsCode

SectionType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Section property - Example
Example

The code below retrieves the SectionHeight settings from the Report, then loops through looking for the Details "a" section, and sets the Height for that section:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionHeight.Retrieve;

for cnt := 0 to (Crpe1.SectionHeight.Count - 1) do

begin

{Look for Details area}

if Crpe1.SectionHeight[cnt].Section = 'Da' then

Crpe1.SectionHeight[cnt].Height := 400;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Create method

See also

Applies to

SectionHeight

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the SectionHeight object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

SectionHeight

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

SectionHeight

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the SectionHeight object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SectionHeight.Retrieve;

  for cnt := 0 to (Crpe1.SectionHeight.Count - 1) do

    Crpe1.SectionHeight[cnt].Height := 500;

end;


Retrieve method

See also	Example

Applies to

SectionHeight

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SectionHeight information from the Report and stores it in the SectionHeight object.  If no SectionHeight information was found, the call returns False.  Be aware that calling Retrieve will first cause the SectionHeight object to be cleared, so any current information stored in it will be removed.

Note

Since the SectionHeight object also applies to Subreports, the Retrieve method will obtain the SectionHeight for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the SectionHeight information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate SectionHeight information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionHeight.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.SectionHeight.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

SectionHeight

Declaration

function Send: boolean;

Description

The Send method sends the SectionHeight values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the SectionHeight settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SectionHeight.Send;


Add method

See also	Example

Applies to

SectionHeight

Declaration

function Add(SectionName: TCrSectionHeightSection): integer;

Type

TCrSectionHeightSection = string;

Description

The Add method adds an item to the SectionHeight object and sets the internal index to that item.  It requires a Section name as a parameter, which should be a name corresponding to a Section in the Report.  Sections are named using the Short Section Name convention used in Crystal Reports (see About Section Names for more information).  If the Add method is used, the steps to using SectionHeight are:

1. Add an item to the SectionHeight object (you must specify the Section name).

2. Fill the Height property with a value.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Section names are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the SectionHeight object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.SectionHeight.Add('PH');

Crpe1.SectionHeight.Height := 500;

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

SectionHeight

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the SectionHeight object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the SectionHeight object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the SectionHeight of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the SectionHeight properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.SectionHeight.Clear;

This code clears the SectionHeight properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.SectionHeight.Clear;

end;


Delete method

See also	Example

Applies to

SectionHeight

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the SectionHeight object.  The "nIndex" parameter represents the number of the item in the SectionHeight object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the SectionHeight object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.SectionHeight.Add('PH');

Crpe1.SectionHeight.Height := 500;

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SectionHeight.Delete(0);


SectionAsCode property

See also	Example

Applies to

SectionHeight

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

Section

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The SectionAsCode property can be used to apply formatting to specific sections based on mathematical calculations or comparisons.  The following code checks each section to see if it is a "b" section, such as RHb, PHb, Db, etc, and if it is, the SectionHeight is changed to 500 twips:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionHeight.Retrieve;

for cnt := 0 to (Crpe1.SectionHeight.Count - 1) do

begin

  if (Crpe1.SectionHeight[cnt].SectionAsCode mod 1000 = 25) then

    Crpe1.SectionHeight[cnt].Height := 500;

end;

Crpe1.Execute;

The logic behind the math expression is based on the fact that each sub-section increments the Section Code number by 25 (from 0 to 975 are the possible numbers).  So, since 3000 is the general Section Code start number for a Group Header, and is therefore the number to represent GroupHeader 1a, 3025 represents GroupHeader 1b, 3050 represents GroupHeader 1c, etc.  Therefore, in order to find the "b" sections we must divide by 1000, and if the remainder is 25, it is a "b" section.  This also works for all the other sections that do not have Group options, such as Details, ReportHeader, etc. since dividing by 25 will also return no remainder if the Section Code number is evenly divisible by 1000.


SectionType method

See also	Example

Applies to

SectionHeight

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1ac, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier.


SectionType method - See also
Related

Section

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionType method - Example
Example

The following example uses the SectionType method to apply conditional formatting.  In this case, we only want to change the SectionHeight for the Group Header sections, so the SectionType method can be used in an expression to apply the changes:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SectionHeight.Retrieve;

  for cnt := 0 to (Crpe1.SectionHeight.Count - 1) do

  begin

    {if the SectionType is Group Header, apply the change}

    if (Crpe1.SectionHeight[cnt].SectionType = 'GH') then

      Crpe1.SectionHeight[cnt].Height := 500;

  end;

end;


CopyFrom method

See also	Example

Applies to

SectionHeight

Declaration

procedure CopyFrom(Source: TCrpeSectionHeight);

Description

The CopyFrom method copies the SectionHeight property values from another TCrpeSectionHeight object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the SectionHeight property values to a temporary TCrpeSectionHeight object:

var

tempSectionHeight : TCrpeSectionHeight;

begin

tempSectionHeight := TCrpeSectionHeight.Create;

tempSectionHeight.CopyFrom(Crpe1.SectionHeight);

{...later, when finished with the temp object...}

tempSectionHeight.Free;

end;


SessionInfo

See also	Properties & Methods	Example

Declaration

property SessionInfo: TCrpeSessionInfo;

Type

TCrpeSessionInfo = class(TPersistent)

Description

SessionInfo contains the properties that set the specified Session Information when opening a Microsoft Access Table that has security.  In Microsoft Access 95 and later, an Access database can have Session security (also known as User-Level security), Database-Level security, or both.

•	SessionInfo works on a table-by-table basis, so after the Retrieve method is called, there is one SessionInfo item in the SessionInfo object for each table in the Report.

•	The Propagate property can be used to apply the property values from the first item to the other items in the SessionInfo object, so it is not necessary to set each one with UserID and Password.

•	The UserID property specifies the user ID value needed for logging on to the system.

•	If the Access database contains only Session security, simply pass the Session Password to the UserPassword property.

•	If the Access database contains database-level security, put the Session Password in the UserPassword property, and the Database-Level Password in the DBPassword property.

•	The Handle property specifies the handle to the current MS Access session.  If the Handle property is not set (the default value is 0), the Crystal Report Engine uses the UserID and UserPassword settings.  In all other cases it uses the Handle value.

•	The default array property, Item, or the ItemIndex property, can be used to navigate through the SessionInfo object.


SessionInfo - See also
Related

Tables

LogOnInfo

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SessionInfo - Properties & Methods
SessionInfo:

Properties & Methods

SessionInfo	TCrpe Component

Properties

UserID

UserPassword

DBPassword

Handle

Propagate

Key

Table

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

Send

Test

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


SessionInfo - Example
Example

The code example below shows how to retrieve the SessionInfo, and then loop through the items to set the UserID and UserPassword before running the Report:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SessionInfo.Retrieve;

  for cnt := 0 to (Crpe1.SessionInfo.Count - 1) do

  begin

    Crpe1.SessionInfo[cnt].UserID := 'Bond';

    Crpe1.SessionInfo[cnt].UserPassword := '007';

  end;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


DBPassword property

See also	Example

Applies to

SessionInfo

Declaration

property DBPassword: string;

Description

The DBPassword property specifies the Database Password for an MS Access table that has Database-Level security.  The combined length of UserPassword and DBPassword must not be greater than 128 characters in length (anything longer than that will be truncated).


DBPassword property - See also
Related

UserID

UserPassword

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DBPassword property - Example
Example

The code example below shows how to retrieve the SessionInfo, and then loop through the items to set the UserID and UserPassword before running the Report:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SessionInfo.Retrieve;

  for cnt := 0 to (Crpe1.SessionInfo.Count - 1) do

    Crpe1.SessionInfo[cnt].DBPassword := '007';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;

The next example does the same as the above, but uses the Propagate property to eliminate the need for a code loop to pass set the information for each table:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SessionInfo.Retrieve;

Crpe1.SessionInfo[0].DBPassword := '007';

Crpe1.SessionInfo.Propagate := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


Handle property

See also

Applies to

SessionInfo

Declaration

property Handle: LongInt;

Description

The Handle property specifies the handle to the MS Access Session, and can be used instead of passing information to the UserID and UserPassword properties.  If the Handle value is 0, the Crystal Report Engine uses the UserID and UserPassword settings.  In all other cases it uses the Handle value.


Handle property - See also
Related

UserID

UserPassword

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property

See also	Example

Applies to

SessionInfo

Declaration

property Item[const nIndex: integer]: TCrpeSessionInfo;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the SessionInfo object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  SessionInfo[2] is the same as SessionInfo.Item[2].

•	Item returns a reference to the SessionInfo object, so the SessionInfo properties can be used right after the subscript: SessionInfo[2].DBPassword := 'myPassword';


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SessionInfo.Retrieve;

{Set SessionInfo object to the 3rd item}

Crpe1.SessionInfo.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SessionInfo.Retrieve;

{Set SessionInfo object to the 3rd item}

Crpe1.SessionInfo[2];


ItemIndex property

See also	Example

Applies to

SessionInfo

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current SessionInfo item number, or set the SessionInfo object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (SessionInfo[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the SessionInfo object is pointing to the first SessionInfo item:

if Crpe1.SessionInfo.ItemIndex <> 0 then

  Crpe1.SessionInfo[0];


Propagate property

See also	Example

Applies to

SessionInfo

Declaration

property Propagate: boolean;

Description

The Propagate property takes the SessionInfo values applied to the first SessionInfo item (which usually points to the first Table in a Report), and applies them to all the other SessionInfo items (or Tables) in the Report.

•	Propagate only applies to the current Report.

•	When setting Propagate for a Subreport, the other Tables in the Subreport will get their SessionInfo settings from the first Table of that Subreport.


Propagate property - See also
Related

Table

UserID

UserPassword

DBPassword

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Propagate property - Example
Example

The code example below shows how to retrieve the SessionInfo, set the first item's UserID and UserPassword, then set the Propagate property to make these values apply to all other items for that Report (but not for Subreports, which must be set separately):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SessionInfo.Retrieve;

Crpe1.SessionInfo[0].UserID := 'Bond';

Crpe1.SessionInfo[0].UserPassword := '007';

Crpe1.SessionInfo.Propagate := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


Table property

See also	Example

Applies to

SessionInfo

Declaration

property Table: TCrSessionInfoTable;

Description

The Table property specifies the Table number of a SessionInfo item.  It's primary use is as a look-up property to point the SessionInfo object to the item with the Table number specified.  The default array property, Item, however, provides an easier way to navigate through the object.

If the Retrieve method is used, the SessionInfo information is retrieved from the Report, and the Table number of each SessionInfo item is automatically filled with values from the Report.  In this case, the Table number and the Item number are usually the same, ie. Table := 0 will point to the same item as SessionInfo[0].


Table property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Table property - Example
Example

The code example below shows how to retrieve the SessionInfo, and then loop through the items to set the UserID and UserPassword before running the Report:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SessionInfo.Retrieve;

  {Set SessionInfo to item with Table number 0}

  Crpe1.SessionInfo.Table := 0;

  Crpe1.SessionInfo.UserID := 'Bond';

  Crpe1.SessionInfo.UserPassword := '007';

  Crpe1.SessionInfo.Propagate := True;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


UserID property

See also	Example

Applies to

SessionInfo

Declaration

property UserID: string;

Description

The UserID property specifies the User ID for an MS Access table that has User-Level security.  UserID is limited to 128 characters in length (anything longer than that will be truncated).


UserID property - See also
Related

UserPassword

DBPassword

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


UserID property - Example
Example

The code example below shows how to retrieve the SessionInfo, and then loop through the items to set the UserID and UserPassword before running the Report:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SessionInfo.Retrieve;

  for cnt := 0 to (Crpe1.SessionInfo.Count - 1) do

  begin

    Crpe1.SessionInfo[cnt].UserID := 'Bond';

    Crpe1.SessionInfo[cnt].UserPassword := '007';

  end;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


UserPassword property

See also	Example

Applies to

SessionInfo

Declaration

property UserPassword: string;

Description

The UserPassword property specifies the password for an MS Access table that has User-Level security.  UserPassword is limited to 128 characters in length (anything longer than that will be truncated).


UserPassword property - See also
Related

UserID

DBPassword

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


UserPassword property - Example
Example

The code example below shows how to retrieve the SessionInfo, and then loop through the items to set the UserID and UserPassword before running the Report:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SessionInfo.Retrieve;

  for cnt := 0 to (Crpe1.SessionInfo.Count - 1) do

  begin

    Crpe1.SessionInfo[cnt].UserID := 'Bond';

    Crpe1.SessionInfo[cnt].UserPassword := '007';

  end;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Create method

See also

Applies to

SessionInfo

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the SessionInfo object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

SessionInfo

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

SessionInfo

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the SessionInfo object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SessionInfo.Retrieve;

  for cnt := 0 to (Crpe1.SessionInfo.Count - 1) do

  begin

    Crpe1.SessionInfo[cnt].UserID := 'Bond';

    Crpe1.SessionInfo[cnt].UserPassword := '007';

  end;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Retrieve method

See also	Example

Applies to

SessionInfo

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SessionInfo information from the Report and stores it in the SessionInfo object.  If no SessionInfo information was found, the call returns False.  Be aware that calling Retrieve will first cause the SessionInfo object to be cleared, so any current information stored in it will be removed.

Note

Since the SessionInfo object also applies to Subreports, the Retrieve method will obtain the SessionInfo for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the SessionInfo information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate SessionInfo information for each Subreport.


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SessionInfo.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.SessionInfo.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

SessionInfo

Declaration

function Send: boolean;

Description

The Send method sends the SessionInfo values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the SessionInfo settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SessionInfo.Send;


Add method

See also	Example

Applies to

SessionInfo

Declaration

function Add(TableNumber: TCrSessionInfoTable): integer;

Type

TCrSessionInfoTable = integer;

Description

The Add method adds an item to the SessionInfo object and sets the internal index to that item.  It requires a Table number as a parameter, which should be a number corresponding to a Table in the Report.  Tables are numbered starting from zero.  If the Add method is used, the steps to using SessionInfo are:

1. Add an item to the SessionInfo object (you must specify the Table number).

2. Fill the item's properties (UserID, UserPassword, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Table numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the SessionInfo object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Table Number - must be same as in Report}

Crpe1.SessionInfo.Add(0);

Crpe1.SessionInfo.UserID := 'Bond';

Crpe1.SessionInfo.UserPassword := '007';

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

SessionInfo

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the SessionInfo object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the SessionInfo object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the SessionInfo of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the SessionInfo properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.SessionInfo.Clear;

This code clears the SessionInfo properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.SessionInfo.Clear;

end;


Delete method

See also	Example

Applies to

SessionInfo

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the SessionInfo object.  The "nIndex" parameter represents the number of the item in the SessionInfo object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the SessionInfo object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Table Number - must be same as in Report}

Crpe1.SessionInfo.Add(0);

Crpe1.SessionInfo.UserID := 'Bond';

Crpe1.SessionInfo.UserPassword := '007';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SessionInfo.Delete(0);


CopyFrom method

See also	Example

Applies to

SessionInfo

Declaration

procedure CopyFrom(Source: TCrpeSessionInfo);

Description

The CopyFrom method copies the SessionInfo property values from another TCrpeSessionInfo object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the SessionInfo property values to a temporary TCrpeSessionInfo object:

var

tempSessionInfo : TCrpeSessionInfo;

begin

tempSessionInfo := TCrpeSessionInfo.Create;

tempSessionInfo.CopyFrom(Crpe1.SessionInfo);

{...later, when finished with the temp object...}

tempSessionInfo.Free;

end;


Test method

See also	Example

Applies to

SessionInfo

Declaration

function Test: boolean;

Description

The Test method can be used to check whether a Table requiring SessionInfo can be connected to.  It returns a boolean result: True means a connection can be made to the Table with the current SessionInfo information; False means a connection cannot be made to the Table.


Test method - See also
Related

DBPassword

UserPassword

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Test method - Example
Example

This example illustrates the use of the Test method:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SessionInfo.Retrieve;

for cnt := 0 to (Crpe1.SessionInfo.Count - 1) do

begin

  Crpe1.SessionInfo[cnt].DBPassword := 'xxx';

  if Crpe1.SessionInfo[cnt].Test then

    ShowMessage('Session is good!')

  else

    ShowMessage('Session is not good!');

end;


GraphType

See also	Properties & Methods	Example

Declaration

property GraphType: TCrpeGraphType;

Type

TCrpeGraphType = class(TPersistent)

Description

The GraphType object contains the properties and methods needed to change the style of the Graphs that are in a Report.

•	The Number property specifies the Graph Number, and can be used as a lookup value to point the GraphType object to a specific GraphType item.  See How Graphs are Numbered for more information on the numbering scheme.

•	The Section property specifies the section that the Graph is located in, and uses the "short" section naming convention used in the Crystal Reports Designer.  See "About Section Names" for more information.

•	The Style property specifies the actual Graph Type.

•	The Retrieve property can be used to fill the GraphType object with information about each Graph.

•	Alternatively, the manual Add method can also be used, but the actual Graph Number as well as the Section it is in will need to be specified.

•	The SectionAsCode property offers the ability to treat the Section name as a Section Code Number, which can be useful for doing mathematical expressions to filter out certain sections.

•	The SectionType method returns just the first characters of the Section name, so for GH1 (Group Header 1), the SectionType would be GH (Group Header).


GraphType - See also
Related

GraphAxis

GraphData

GraphOptions

GraphOptionInfo

GraphText

How Graphs are Numbered

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GraphType - Properties & Methods
GraphType:

Properties & Methods

GraphType	TCrpe Component

Properties

Style

SectionAsCode

Key

Number

Location

Section

SectionAsCode

SectionGraphNum

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

IndexOf

Retrieve

Send

SectionType

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


GraphType - Example
Example

This example retrieves the GraphType information from the Report and then changes the Style to 3D Bars:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphType.Retrieve;

if Crpe1.GraphType.Count > 0 then

begin

  Crpe1.GraphType[0].Style := bar3DSideBySide;

  Crpe1.Execute;

end;


Item property

See also	Example

Applies to

GraphType

Declaration

property Item[const nIndex: integer]: TCrpeGraphType;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the GraphType object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  GraphType[2] is the same as GraphType.Item[2].

•	Item returns a reference to the GraphType object, so the GraphType properties can be used right after the subscript: GraphType[2].Style := SideBySide;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphType.Retrieve;

{Set GraphType object to the 2nd graph}

Crpe1.GraphType.Item[1];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphType.Retrieve;

{Set GraphType object to the 2nd graph}

Crpe1.GraphType[1];


ItemIndex property

See also	Example

Applies to

GraphType

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GraphType item number, or set the GraphType object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (GraphType[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the GraphType object is pointing to the first GraphType item:

if Crpe1.GraphType.ItemIndex <> 0 then

  Crpe1.GraphType[0];


Number property

See also	Example

Applies to

GraphType

Declaration

property Number: TCrGraphTypeNumber;

Type

TCrGraphTypeNumber = integer;

Description

The Number property specifies the Graph Number.

•	If the Retrieve method is used to fill the GraphType object with infomation from the Report, each GraphType item will have a unique Graph Number assigned by the VCL.

•	If the manual Add method is used instead, a Graph number will have to be specifed which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered).

The primary use of the Number property is as a look-up to point the GraphType object to the item with the Graph number specified.  The default array property, Item, however, provides an easier way to navigate through the object.


Number property - See also
Related

Item

ItemIndex

SectionGraphNum

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

This example retrieves the GraphType information from the Report and then changes the Style to 3D Bars:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphType.Retrieve;

if Crpe1.GraphType.Count > 0 then

begin

  {Set the GraphType object to Graph number 0}

  Crpe1.GraphType.Number := 0;

  Crpe1.GraphType.Style := bar3DSideBySide;

  Crpe1.Execute;

end;


Section property

See also	Example

Applies to

GraphType

Declaration

property Section: string;

Description

The Section property contains the Section name of the item that the GraphType object is currently pointed to.  It indicates in which Section of the Report that the Graph is located.

Note that you cannot move a Graph from one Section to another by changing this property.  It should primarily be used as a read-only property after the GraphType information has been retrieved with the Retrieve method.  If the manual Add method is used to add items to the GraphType object, then Section will have to be assigned the correct value in code.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections.  Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.


Section property - See also
Related

SectionAsCode

SectionType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Section property - Example
Example

This example retrieves the GraphType information from the Report and then changes the Style to 3D Bars only for those Graphs that reside in the Page Header:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphType.Retrieve;

for cnt := 0 to (Crpe1.GraphType.Count - 1) do

begin

  if Crpe1.GraphType[cnt].Section = 'PH' then

    Crpe1.GraphType[cnt].Style := bar3DSideBySide;

end;

Crpe1.Execute;


Style property

See also	Example

Applies to

GraphType

Declaration

property Style: TCrGraphType;

Type

  TCrGraphType = (

    {Bar: 0..5}

    barSideBySide, barStacked, barPercent, bar3DSideBySide, bar3DStacked,

    bar3DPercent,

    {Line: 6..11}

    lineRegular, lineStacked, linePercent, lineWithMarkers,

    lineStackedWithMarkers, linePercentWithMarkers,

    {Area: 12..17}

    areaAbsolute, areaStacked, areaPercent, area3DAbsolute, area3DStacked,

    area3DPercent,

    {Pie: 18..21}

    pieRegular, pie3DRegular, pieMultiple, pieMultiProp,

    {Doughnut: 22..24}

    doughnutRegular, doughnutMultiple, doughnutMultiProp,

    {3D Riser: 25..28}

    ThreeDRegular, ThreeDPyramid, ThreeDOctagon, ThreeDCutCorners,

    {3D Surface: 29..31}

    ThreeDSurfaceRegular, ThreeDSurfaceWithSides, ThreeDSurfaceHoneyComb,

    {XYScatter: 32..35}

    XYScatter, XYScatterDualAxis, XYScatterLabeled, XYScatterDualAxisLabeled,

    {Radar: 36..38}

    radarRegular, radarStacked, radarDualAxis,

    {Bubble: 39,40}

    bubbleRegular, bubbleDualAxis,

    {StockHiLo: 41..46}

    stockHiLo, stockHiLoDualAxis, stockHiLoOpen, stockHiLoOpenDualAxis,

    stockHiLoOpenClose, stockHiLoOpenCloseDualAxis,

    {User Defined: 47}

    userDefinedGraph,

    {Unknown: 48..59}

    unknownBar, unknownLine, unknownArea, unknownPie, unknownDoughnut,

    unknown3DRiser, unknown3DSurface, unknownXYScatter, unknownRadar,

    unknownBubble, unknownStockHiLo, unknownGraphType);

Description

The Style property determines the type of Graph that will be displayed in the Report.  For Crystal Reports 5 & 6, only the following styles are available:

barSideBySide

bar3DSideBySide

barStacked

bar3DStacked

barPercent

bar3DPercent

lineRegular

areaAbsolute

ThreeDRegular

pieRegular

pieMultiple

pieMultiProp

The UserDefined and UnknownGraph types (which are not represented in the picture above) represent the following:

userDefinedGraph	- The Graph has been edited in PG Editor.  Some of the Graph changes via the VCL may not affect options that have been customized in PG Editor.

unknownXXX	- The Print Engine cannot recognize the Graph.  This shouldn't happen, but if it does, it is likely that changes to the Graph via the VCL may not work properly.  In this case, the Report should be opened in Crystal Reports and re-saved, or the Graph should be re-inserted.


Style property - See also
Related

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Style property - Example
Example

This example retrieves the GraphType information from the Report and then changes the Style to 3D Bars:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphType.Retrieve;

if Crpe1.GraphType.Count > 0 then

begin

  Crpe1.GraphType[0].Style := bar3DSideBySide;

  Crpe1.Execute;

end;


Create method

See also

Applies to

GraphType

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the GraphType object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

GraphType

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

GraphType

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the GraphType object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphType.Retrieve;

  for cnt := 0 to (Crpe1.GraphType.Count - 1) do

    Crpe1.GraphType[cnt].Style := bar3DSideBySide;

end;


Retrieve method

See also	Example

Applies to

GraphType

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the GraphType information from the Report and stores it in the GraphType object.  If no GraphType information was found, the call returns False.  Be aware that calling Retrieve will first cause the GraphType object to be cleared, so any current information stored in it will be removed.

Note

Since the GraphType object also applies to Subreports, the Retrieve method will obtain the GraphType for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the GraphType information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate GraphType information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphType.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.GraphType.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

GraphType

Declaration

function Send: boolean;

Description

The Send method sends the GraphType values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the GraphType settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.GraphType.Send;


Add method

See also	Example

Applies to

GraphType

Declaration

function Add(GraphNumber: TCrGraphTypeNumber): integer;

Type

TCrGraphTypeNumber = integer;

Description

The Add method adds an item to the GraphType object and sets the internal index to that item.  It requires a Graph number as a parameter, which should be a number corresponding to a Graph in the Report.  Graphs are numbered starting from zero, from the top of the Report down, and left to right in each Section.  If the Add method is used, the steps to using GraphType are:

1. Add an item to the GraphType object (you must specify the Graph number).

2. Fill the item's properties (Section, Style, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Graph numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the GraphType object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Graph number - must be same as in Report}

Crpe1.GraphType.Add(0);

{Section must also be specified when using Add}

Crpe1.GraphType.Section := 'PH';

Crpe1.GraphType.Style := bar3DSideBySide;

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

GraphType

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GraphType object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the GraphType object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the GraphType of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the GraphType properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.GraphType.Clear;

This code clears the GraphType properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.GraphType.Clear;

end;


Delete method

See also	Example

Applies to

GraphType

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the GraphType object.  The "nIndex" parameter represents the number of the item in the GraphType object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the GraphType object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Graph number - must be same as in Report}

Crpe1.GraphType.Add(0);

{Section must also be specified when using Add}

Crpe1.GraphType.Section := 'PH';

Crpe1.GraphType.Style := bar3DSideBySide;

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.GraphType.Delete(0);


SectionAsCode property

See also	Example

Applies to

GraphType

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to use them in mathematical expressions or relationships than to the actual Section names (GH1b, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

Section

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The following example uses the SectionAsCode property to apply conditional changes to Graphs.  In this case, there is a Graph in each of three Group Header sections (GH1a, GH2a, GH3a).  Since the Section Code for GH1a is 3000, GH2a is 3001, and GH3a is 3002, it is possible to do a simple mathematical calculation on the remainder of the Section Code divided by 1000 to change the style of the Graphs only if it is not in GH1:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphType.Retrieve;

  for cnt := 0 to (Crpe1.GraphType.Count - 1) do

  begin

    {if the remainder of the SectionCode divided by 1000

     is greater than zero, then apply the change}

    if (Crpe1.GraphType[cnt].SectionAsCode mod 1000 > 0) then

      Crpe1.GraphType[cnt].Style := pie3DRegular;

  end;

end;


SectionType method

See also	Example

Applies to

GraphType

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1ac, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier.  See the Example for an illustration.


SectionType method - See also
Related

Section

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionType method - Example
Example

The following example uses the SectionType method to apply conditional changes to Graphs.  In this case, there is a Graph in each of three sections (RH, GH1a, GH2a).  Only the Graphs in the Group Headers should be changed, so the SectionType method can be used in an expression to apply the changes:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphType.Retrieve;

  for cnt := 0 to (Crpe1.GraphType.Count - 1) do

  begin

    {if the SectionType is GroupHeader, apply the change}

    if (Crpe1.GraphType[cnt].SectionType = 'GH') then

      Crpe1.GraphType[cnt].Style := pie3DRegular;

  end;

end;


How Graphs are Numbered

The Crystal Reports Print Engine numbers Graphs from top to bottom and left to right within a Section.  Therefore, it is possible to have more than one Graph with the same number, since they reside in different sections.  This is why it is necessary to specify both a Graph Number, and a Graph Section for each Graph that will be changed.  In the Crystal Reports VCL component, there are two ways of dealing with Graph numbering:

The Retrieve method

If the Retrieve method is used for obtaining Graph information (GraphType, GraphText, GraphOptions, GraphData) from a Report, then the Crystal component stores the actual Print Engine Graph Number internally, and uses a modified numbering system for the Number property, whereby the Graphs are numbered per Report, and not per Section.  In this way, each Graph has a unique Number value.  The Section property still shows the proper Section value, but the Graphs are numbered uniquely, so there are no duplicates.  This was necessary so that Number could be used as a lookup property in the Object Inspector.

The Add method

If the Add method is used to manually add an Graph item to one of the VCL component's Graph objects (GraphType, GraphData, GraphOptions, GraphText), then the original Print Engine numbering scheme should be used.  This requires that the developer have a good knowledge of what each Report contains, and where the Graphs are placed.

It is recommended that the Retrieve method be used as much as possible, as it is less error-prone, does not require the developer to know before-hand the actual Graph number and Section for each Graph, and is easier to deal with (ie. no duplicate numbers).


CopyFrom method

See also	Example

Applies to

GraphType

Declaration

procedure CopyFrom(Source: TCrpeGraphType);

Description

The CopyFrom method copies the GraphType property values from another TCrpeGraphType object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the GraphType property values to a temporary TCrpeGraphType object:

var

tempGraphType : TCrpeGraphType;

begin

tempGraphType := TCrpeGraphType.Create;

tempGraphType.CopyFrom(Crpe1.GraphType);

{...later, when finished with the temp object...}

tempGraphType.Free;

end;


SectionGraphNum property

See also	Example

Applies to

GraphType

Declaration

property SectionGraphNum: smallint;

Description

The SectionGraphNum property specifies the Graph Number as numbered from left to right within the Section it resides.  This is the numbering scheme used by the Print Engine, however the Crystal VCL also uses its own numbering scheme which is reflected in the Number property (so that each Graph has a unique number).

•	If the Retrieve method is used to fill the GraphType object with infomation from the Report, the SectionGraphNum values are retrieved automatically.

•	If the manual Add method is used instead, a SectionGraphNum value will have to be specifed which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered).

This property is mainly provided for those who wish to use the manual Add method.


SectionGraphNum property - See also
Related

Item

ItemIndex

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionGraphNum property - Example
Example

This example manually adds an item to the GraphType class and sets the SectionGraphNum accordingly:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

nItem := Crpe1.GraphType.Add(0);

Crpe1.GraphType[nItem].SectionGraphNum := 0;

Crpe1.GraphType[nItem].Style := pie3DRegular;

Crpe1.Execute;

end;


IndexOf method

See also	Example

Applies to

GraphType

Declaration

function IndexOf(GraphNumber: TCrGraphTypeNumber): integer;

Type

TCrGraphTypeNumber = integer;

Description

The IndexOf method takes a Graph Number and returns the index position of the GraphType item in the GraphType class.


IndexOf method - See also
Related

Item

ItemIndex

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

The following code illustrates the use of the IndexOf method to locate a specific GraphType item:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphType.Retrieve;

{Find the second Graph}

nItem := Crpe1.GraphType.IndexOf(1);

{If it exists...}

if nItem > -1 then

  {Change the Style to ThreeDBars}

Crpe1.GraphType[nItem].Style := pie3DRegular;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


GraphData

See also	Properties & Methods	Example

Declaration

property GraphData: TCrpeGraphData;

Type

TCrpeGraphData = class(TPersistent)

Description

The GraphData object contains the properties and methods required to change the data that a Graph is based on.

•	The Number property specifies the Graph Number, and can be used as a lookup value to point the GraphType object to a specific GraphType item.  See How Graphs are Numbered for more information on the numbering scheme.

•	The Section property specifies the section that the Graph is located in, and uses the "short" section naming convention used in the Crystal Reports Designer.  See "About Section Names" for more information.

•	The Retrieve method can be used to fill the GraphData object with information from the Report.

•	The Count method will indicate the number of GraphData items currently stored in the GraphData object.

•	The Item, and ItemIndex properties can be used to navigate through the GraphData items in the GraphData object.

•	The RowGroupN property specifies which Group number in the report is used to create the values in the rows of the Graph. Use -1 for default.  Group numbers start with 1.

•	The ColGroupN property specifies which Group number in the report is used to create the values in the columns of the Graph. Use -1 for Default.  Group numbers start with 1.

•	The SummarizedFieldN property specifies which Summary field in the report is used to set the values of the risers in the Graph. Summary fields are numbered in order of their creation. Use -1 for default.  Summary Field numbers start with 0.

•	The Direction property is used to specify in what direction a Graph will read it's data from the Report.  For normal Group/Total report, the Direction, is always Cols. For Cross-Tab Reports, use any of the following TCrGraphDirection values:

TCrGraphDirection	Meaning

Rows	Use only row values in graph.

Cols	Use only column values in graph.

RowCol	Graph by row values, then by column values.

ColRow	Graph by column values, then by row values.

Unknown	The direction of the graph is unknown.

•	The SectionAsCode property offers the ability to treat the Section name as a Section Code Number, which can be useful for doing mathematical expressions to filter out certain sections.

•	The SectionType method returns just the first characters of the Section name, so for GH1 (Group Header 1), the SectionType would be GH (Group Header).

Note

Graphs based on Formulas or Details instead of Groups, will not have GraphData.


GraphData - See also
Related

GraphOptions

GraphText

GraphType

How Graphs are Numbered

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GraphData - Properties & Methods
GraphData:

Properties & Methods

GraphData	TCrpe Component

Properties

ColGroupN

Direction

RowGroupN

SummarizedFieldN

Key

Number

Location

Section

SectionAsCode

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


GraphData - Example
Example

The sample code below illustrates the use of the GraphData object to change the Summary Field that the Graph is based on:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

if Crpe1.GraphData.Count > 0 then

  Crpe1.GraphData[0].SummarizedFieldN := 1;

Crpe1.Execute;


ColGroupN property

See also	Example

Applies to

GraphData

Declaration

property ColGroupN: smallint;

Description

The ColGroupN property specifies which Group number in the Report is used to create the values in the columns of the Graph.

•	Group numbers start with 1.

•	Use -1 for Default (no change).


ColGroupN property - See also
Related

RowGroupN

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ColGroupN property - Example
Example

The sample code below illustrates the use of the GraphData object to change the Group Field that Columns of the Graph are based on:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

if Crpe1.GraphData.Count > 0 then

  Crpe1.GraphData[0].ColGroupN := 2;

Crpe1.Output := toWindow;

Crpe1.Execute;


Direction property

See also	Example

Applies to

GraphData

Declaration

property Direction: TCrGraphDirection;

Type

TCrGraphDirection = (Rows, Cols, RowCol, ColRow, Unknown);

Description

The Direction property is used to specify in what direction a Graph will read it's data from the Report.

•	For normal Group/Total report, the Direction, is always Cols.

•	For Cross-Tab Reports, use any of the following TCrGraphDirection values:

TCrGraphDirection	Meaning

Rows	Use only row values in graph.

Cols	Use only column values in graph.

RowCol	Graph by row values, then by column values.

ColRow	Graph by column values, then by row values.

Unknown	The direction of the graph is unknown.


Direction property - See also
Related

ColGroupN

RowGroupN

SummarizedFieldN

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Direction property - Example
Example

The sample code below illustrates the use of the GraphData object to change the Direction in which the Graph will read it's data from the Report.  In this case, the Report is a Cross Tab Report (which is a requirement in order to change the Direction), and the Graph will read it's data from the Rows:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

if Crpe1.GraphData.Count > 0 then

  Crpe1.GraphData[0].Direction := Rows;

Crpe1.Output := toWindow;

Crpe1.Execute;


Item property

See also	Example

Applies to

GraphData

Declaration

property Item[const nIndex: integer]: TCrpeGraphData;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the GraphData object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  GraphData[2] is the same as GraphData.Item[2].

•	Item returns a reference to the GraphData object, so the GraphData properties can be used right after the subscript: GraphData[2].SummarizedFieldN := 1;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

{Set GraphData object to the 2nd graph}

Crpe1.GraphData.Item[1];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

{Set GraphData object to the 2nd graph}

Crpe1.GraphData[1];


ItemIndex property

See also	Example

Applies to

GraphData

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GraphData item number, or set the GraphData object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (GraphData[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the GraphData object is pointing to the first GraphData item:

if Crpe1.GraphData.ItemIndex <> 0 then

  Crpe1.GraphData[0];


Number property

See also	Example

Applies to

GraphData

Declaration

property Number: TCrGraphDataNumber;

Type

TCrGraphDataNumber = integer;

Description

The Number property specifies the Graph Number.

•	If the Retrieve method is used to fill the GraphData object with infomation from the Report, each GraphData item will have a unique Graph Number assigned by the VCL.

•	If the manual Add method is used instead, a Graph number will have to be specifed which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered).

The primary use of the Number property is as a look-up to point the GraphData object to the item with the Graph number specified.  The default array property, Item, however, provides an easier way to navigate through the object.


Number property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

The sample code below illustrates the use of the Number property to navigate the GraphData object to the item that specifies the details for Graph number 0 (the first Graph in the Report):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

Crpe1.GraphData.Number := 0;

Crpe1.GraphData.SummarizedFieldN := 2;

Crpe1.Execute;


RowGroupN property

See also	Example

Applies to

GraphData

Declaration

property RowGroupN: smallint;

Description

The RowGroupN property specifies which Group number in the report is used to create the values in the Rows of the Graph.

•	Group numbers start with 1.

•	Use -1 for default (no change).


RowGroupN property - See also
Related

ColGroupN

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


RowGroupN property - Example
Example

The sample code below illustrates the use of the GraphData object to change the Group Field that Rows of the Graph are based on:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

if Crpe1.GraphData.Count > 0 then

  Crpe1.GraphData[0].RowGroupN := 2;

Crpe1.Output := toWindow;

Crpe1.Execute;


Section property

See also	Example

Applies to

GraphData

Declaration

property Section: string;

Description

The Section property contains the Section name of the item that the GraphData object is currently pointed to.  It indicates in which Section of the Report that the Graph is located.

Note that you cannot move a Graph from one Section to another by changing this property.  It should primarily be used as a read-only property after the GraphData information has been retrieved with the Retrieve method.  If the manual Add method is used to add items to the GraphData object, then Section will have to be assigned the correct value in code.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections.  Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.


Section property - See also
Related

SectionAsCode

SectionType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Section property - Example
Example

The sample code applies a change only to those Graphs which are located in Group Header 1 (GH1):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

for cnt := 0 to (Crpe1.GraphData.Count - 1) do

begin

  if Crpe1.GraphData[cnt].Section = 'GH1' then

    Crpe1.GraphData[cnt].SummarizedFieldN := 2;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


SummarizedFieldN property

See also	Example

Applies to

GraphData

Declaration

property SummarizedFieldN: smallint;

Description

The SummarizedFieldN property specifies which Summary field in the report is used to set the values of the Risers in the Graph.

•	Summary fields are numbered in order of their creation.

•	Summary Field numbers start with 0.

•	Use -1 for default (no change).


SummarizedFieldN property - See also
Related

ColGroupN

RowGroupN

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SummarizedFieldN property - Example
Example

The sample code below illustrates the use of the GraphData object to change the Summary Field that the Graph is based on:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

if Crpe1.GraphData.Count > 0 then

  Crpe1.GraphData[0].SummarizedFieldN := 2;

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

GraphData

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the GraphData object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

GraphData

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

GraphData

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the GraphData object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphData.Retrieve;

  for cnt := 0 to (Crpe1.GraphData.Count - 1) do

    Crpe1.GraphData[cnt].SummarizedFieldN := 2;

end;


Retrieve method

See also	Example

Applies to

GraphData

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the GraphData information from the Report and stores it in the GraphData object.  If no GraphData information was found, the call returns False.  Be aware that calling Retrieve will first cause the GraphData object to be cleared, so any current information stored in it will be removed.

Note

Since the GraphData object also applies to Subreports, the Retrieve method will obtain the GraphData for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the GraphData information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate GraphData information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.GraphData.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

GraphData

Declaration

function Send: boolean;

Description

The Send method sends the GraphData values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the GraphData settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.GraphData.Send;


Add method

See also	Example

Applies to

GraphData

Declaration

function Add(GraphNumber: TCrGraphDataNumber): integer;

Type

TCrGraphDataNumber = integer;

Description

The Add method adds an item to the GraphData object and sets the internal index to that item.  It requires a Graph number as a parameter, which should be a number corresponding to a Graph in the Report.  Graphs are numbered starting from zero, from the top of the Report down, and left to right in each Section.  If the Add method is used, the steps to using GraphData are:

1. Add an item to the GraphData object (you must specify the Graph number).

2. Fill the item's properties (ColGroupN, RowGroupN, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Graph numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the GraphData object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Graph Number - must be same as in Report}

Crpe1.GraphData.Add(0);

{Section must also be specified when using Add}

Crpe1.GraphData.Section := 'PH';

Crpe1.GraphData.SummarizedFieldN := 2;

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

GraphData

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GraphData object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the GraphData object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the GraphData of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the GraphData properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.GraphData.Clear;

This code clears the GraphData properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.GraphData.Clear;

end;


Delete method

See also	Example

Applies to

GraphData

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the GraphData object.  The "nIndex" parameter represents the number of the item in the GraphData object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the GraphData object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Graph Number - must be same as in Report}

Crpe1.GraphData.Add(0);

{Section must also be specified when using Add}

Crpe1.GraphData.Section := 'PH';

Crpe1.GraphData.SummarizedFieldN := 2;

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.GraphData.Delete(0);


SectionAsCode property

See also	Example

Applies to

GraphData

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

Section

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The following example uses the SectionAsCode property to apply conditional changes to a Graph.  In this case, there is a Graph in each of three Group Header sections (GH1a, GH2a, GH3a).  Since the Section Code for GH1a is 3000, GH2a is 3001, and GH3a is 3002, it is possible to do a simple mathematical calculation on the remainder of the Section Code divided by 1000 to change the style of the Graph only if it is in GH1:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphData.Retrieve;

  for cnt := 0 to (Crpe1.GraphData.Count - 1) do

  begin

{if the remainder of the SectionCode divided by 1000 is greater than zero, then apply the change}

if (Crpe1.GraphData[cnt].SectionAsCode mod 1000 = 0) then

  Crpe1.GraphData[cnt].SummarizedFieldN := 1;

end;

end;


SectionType method

See also	Example

Applies to

GraphData

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1ac, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier.  See the Example for an illustration.


SectionType method - See also
Related

Section

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionType method - Example
Example

The following example uses the SectionType method to apply conditional changes to Graphs.  In this case, there is a Graph in each of three sections (RH, GH1a, GH2a).  Only the Graphs in the Group Headers should be changed, so the SectionType method can be used in an expression to apply the changes:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphData.Retrieve;

  for cnt := 0 to (Crpe1.GraphData.Count - 1) do

  begin

    {if the SectionType is GroupHeader, apply the change}

    if (Crpe1.GraphData[cnt].SectionType = 'GH') then

      Crpe1.GraphData[cnt].SummarizedFieldN := 1;

  end;

end;


CopyFrom method

See also	Example

Applies to

GraphData

Declaration

procedure CopyFrom(Source: TCrpeGraphData);

Description

The CopyFrom method copies the GraphData property values from another TCrpeGraphData object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the GraphData property values to a temporary TCrpeGraphData object:

var

tempGraphData : TCrpeGraphData;

begin

tempGraphData := TCrpeGraphData.Create;

tempGraphData.CopyFrom(Crpe1.GraphData);

{...later, when finished with the temp object...}

tempGraphData.Free;

end;


GraphText

See also	Properties & Methods	Example

Declaration

property GraphText: TCrpeGraphText;

Type

TCrpeGraphText = class(TPersistent)

Description

The GraphText object contains the properties and methods required to change the text on a Graph.

•	The Number property specifies the Graph Number, and can be used as a lookup value to point the GraphType object to a specific GraphType item.  See How Graphs are Numbered for more information on the numbering scheme.

•	The Section property specifies the section that the Graph is located in, and uses the "short" section naming convention used in the Crystal Reports Designer.  See "About Section Names" for more information.

•	The Retrieve method can be used to fill the GraphText object with information from the Report.

•	The Count method will indicate how many GraphText items are currently in the GraphText object.

•	The Item and ItemIndex properties can be used to navigate through the GraphText items in the GraphText object.

•	The Title and TitleFont properties specify the main title text that will appear above the Graph.

•	The SubTitle and SubTitleFont properties specify the sub title text that will appear directly under the main Title.

•	The FootNote and FootNoteFont properties specify the footnote text that will appear under the Graph.

•	The GroupsTitle and GroupsTitleFont properties specify the title of the Groups which are being graphed.

•	The SeriesTitle and DataTitleFont properties specify the title of the Series which is being graphed.

•	The LegendFont property specifies the font that will be used in the Graph legend.

•	The XAxisTitle property specifies the title text that will appear for the X axis. Not valid for Pie graphs.

•	The YAxisTitle property specifies the title text that will appear for the Y axis. Not valid for Pie graphs.

•	The ZAxisTitle property specifies the title text that will appear for the Z axis. This value is only valid for 3D graphs.

•	The GroupLabelsFont property specifies the font for the group axis of the graph.  On a vertical bar graph, this would be the horizontal axis.

•	The DataLabelsFont property specifies the font for the data axis of the Graph.  On a vertical bar graph, this would be the vertical axis.


GraphText - See also
Related

GraphData

GraphOptions

GraphType

How Graphs are Numbered

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GraphText - Properties & Methods
GraphText:

Properties & Methods

GraphText	TCrpe Component

Properties

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Font (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

Key

Number

Location

Section

SectionAsCode

Navigation

Item

ItemIndex

Method

Clear

CopyFrom

Count

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


GraphText - Example
Example

The following example retrieves the GraphText information from the Report, then changes the various GraphText properties for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

begin

  Crpe1.GraphText[0].Title := 'New Title';

  Crpe1.GraphText[0].SubTitle := 'New Sub Title';

  Crpe1.GraphText[0].SeriesTitle := 'New Series Title';

  Crpe1.GraphText[0].FootNote := 'New FootNote';

  Crpe1.GraphText[0].GroupsTitle := 'New Groups Title';

  Crpe1.GraphText[0].SeriesTitle := 'New Series Title';

  Crpe1.GraphText[0].XAxisTitle := 'New XAxis Title';

  Crpe1.GraphText[0].YAxisTitle := 'New YAxis Title';

  Crpe1.GraphText[0].ZAxisTitle := 'New ZAxis Title';

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


FootNote property

See also	Example

Applies to

GraphText

Declaration

property FootNote: TCrGraphTextType;

Type

TCrGraphTextType = string;

Description

The FootNote property specifies the footnote text that will appear under the Graph.  It is limited to 128 characters in length (anything greater than that will be truncated).


FootNote property - See also
Related

Title

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

Font (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


FootNote property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the FootNote text for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

  Crpe1.GraphText[0].FootNote := 'New FootNote';

Crpe1.Output := toWindow;

Crpe1.Execute;


GroupsTitle property

See also	Example

Applies to

GraphText

Declaration

property GroupsTitle: TCrGraphTextType;

Type

TCrGraphTextType = string;

Description

The GroupsTitle property specifies the title of the Groups which are being graphed.  It is limited to 128 characters in length (anything greater than that will be truncated).


GroupsTitle property - See also
Related

Title

Title

SubTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Font (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupsTitle property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the GroupsTitle for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

  Crpe1.GraphText[0].GroupsTitle := 'New Groups Title';

Crpe1.Output := toWindow;

Crpe1.Execute;


Item property

See also	Example

Applies to

GraphText

Declaration

property Item[const nIndex: integer]: TCrpeGraphText;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the GraphText object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  GraphText[2] is the same as GraphText.Item[2].

•	Item returns a reference to the GraphText object, so the GraphText properties can be used right after the subscript: GraphText[2].Title := 'NewGraph';


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

{Set GraphText object to the 2nd graph}

Crpe1.GraphText.Item[1];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

{Set GraphText object to the 2nd graph}

Crpe1.GraphText[1];


ItemIndex property

See also	Example

Applies to

GraphText

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GraphText item number, or set the GraphText object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (GraphText[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the GraphText object is pointing to the first GraphText item:

if Crpe1.GraphText.ItemIndex <> 0 then

  Crpe1.GraphText[0];


Number property

See also	Example

Applies to

GraphText

Declaration

property Number: TCrGraphTextNumber;

Type

TCrGraphTextNumber = integer;

Description

The Number property specifies the Graph Number.

•	If the Retrieve method is used to fill the GraphText object with infomation from the Report, each GraphText item will have a unique Graph Number assigned by the VCL.

•	If the manual Add method is used instead, a Graph number will have to be specifed which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered).

The primary use of the Number property is as a look-up to point the GraphText object to the item with the Graph number specified.  The default array property, Item, however, provides an easier way to navigate through the object.


Number property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

The following example uses the Number property to navigate the GraphText object to a specific item whose properties are then changed:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

begin

  Crpe1.GraphText.Number := 0;

  Crpe1.GraphText.XAxisTitle := 'New XAxis Title';

  Crpe1.GraphText.YAxisTitle := 'New YAxis Title';

  Crpe1.GraphText.ZAxisTitle := 'New ZAxis Title';

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


Section property

See also	Example

Applies to

GraphText

Declaration

property Section: string;

Description

The Section property contains the Section name of the item that the GraphText object is currently pointed to.  It indicates in which Section of the Report that the Graph is located.

Note that you cannot move a Graph from one Section to another by changing this property.  It should primarily be used as a read-only property after the GraphText information has been retrieved with the Retrieve method.  If the manual Add method is used to add items to the GraphText object, then Section will have to be assigned the correct  value in code.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections.  Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.


Section property - See also
Related

SectionAsCode

SectionType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Section property - Example
Example

The Section property can be used to apply conditional changes to GraphText (ie. only those items that are in the Page Header are affected in the following example):

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

for cnt := 0 to (Crpe1.GraphText.Count - 1) then

begin

  if Crpe1.GraphText[cnt].Section = 'PH' then

  begin

    Crpe1.GraphText[cnt].XAxisTitle := 'New XAxis Title';

    Crpe1.GraphText[cnt].YAxisTitle := 'New YAxis Title';

    Crpe1.GraphText[cnt].ZAxisTitle := 'New ZAxis Title';

  end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


SeriesTitle property

See also	Example

Applies to

GraphText

Declaration

property SeriesTitle: TCrGraphTextType;

Type

TCrGraphTextType = string;

Description

The SeriesTitle property specifies the title of the Series which is being graphed.  It is limited to 128 characters in length (anything greater than that will be truncated).


SeriesTitle property - See also
Related

Title

Title

SubTitle

GroupsTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Font (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SeriesTitle property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the SeriesTitle for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

  Crpe1.GraphText[0].SeriesTitle := 'New Series Title';

Crpe1.Output := toWindow;

Crpe1.Execute;


SubTitle property

See also	Example

Applies to

GraphText

Declaration

property SubTitle: TCrGraphTextType;

Type

TCrGraphTextType = string;

Description

The SubTitle property specifies the sub title text that will appear directly under the main Title.  It is limited to 128 characters in length (anything greater than that will be truncated).


SubTitle property - See also
Related

Title

Title

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Font (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SubTitle property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the SubTitle for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

  Crpe1.GraphText[0].SubTitle := 'New Sub Title';

Crpe1.Output := toWindow;

Crpe1.Execute;


Title property

See also	Example

Applies to

GraphText

Declaration

property Title: TCrGraphTextType;

Type

TCrGraphTextType = string;

Description

The Title property specifies the main title text that will appear above the Graph.  It is limited to 128 characters in length (anything greater than that will be truncated).


Title property - See also
Related

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Font (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Title property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the Title for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

  Crpe1.GraphText[0].Title := 'New Title';

Crpe1.Output := toWindow;

Crpe1.Execute;


XAxisTitle property

See also	Example

Applies to

GraphText

Declaration

property XAxisTitle: TCrGraphTextType;

Type

TCrGraphTextType = string;

Description

The XAxisTitle property specifies the title text that will appear for the X axis. Not valid for Pie graphs.  It is limited to 128 characters in length (anything greater than that will be truncated).


XAxisTitle property - See also
Related

Title

Title

SubTitle

GroupsTitle

SeriesTitle

YAxisTitle

ZAxisTitle

FootNote

Font (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


XAxisTitle property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the XAxisTitle for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

  Crpe1.GraphText[0].XAxisTitle := 'New XAxis Title';

Crpe1.Output := toWindow;

Crpe1.Execute;


YAxisTitle property

See also	Example

Applies to

GraphText

Declaration

property YAxisTitle: TCrGraphTextType;

Type

TCrGraphTextType = string;

Description

The YAxisTitle property specifies the title text that will appear for the Y axis. Not valid for Pie graphs.  It is limited to 128 characters in length (anything greater than that will be truncated).


YAxisTitle property - See also
Related

Title

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

ZAxisTitle

FootNote

Font (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


YAxisTitle property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the YAxisTitle for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

  Crpe1.GraphText[0].YAxisTitle := 'New YAxis Title';

Crpe1.Output := toWindow;

Crpe1.Execute;


ZAxisTitle property

See also	Example

Applies to

GraphText

Declaration

property ZAxisTitle: TCrGraphTextType;

Type

TCrGraphTextType = string;

Description

The ZAxisTitle property specifies the title text that will appear for the Z axis. This value is only valid for 3D graphs.  It is limited to 128 characters in length (anything greater than that will be truncated).


ZAxisTitle property - See also
Related

Title

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

FootNote

Font (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ZAxisTitle property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the ZAxisTitle for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

  Crpe1.GraphText[0].ZAxisTitle := 'New ZAxis Title';

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

GraphText

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the GraphText object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

GraphText

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

GraphText

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the GraphText object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphText.Retrieve;

  for cnt := 0 to (Crpe1.GraphText.Count - 1) do

    Crpe1.GraphText[cnt].Title := 'Company Graph';

end;


Retrieve method

See also	Example

Applies to

GraphText

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the GraphText information from the Report and stores it in the GraphText object.  If no GraphText information was found, the call returns False.  Be aware that calling Retrieve will first cause the GraphText object to be cleared, so any current information stored in it will be removed.

Note

Since the GraphText object also applies to Subreports, the Retrieve method will obtain the GraphText for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the GraphText information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate GraphText information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.GraphText.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

GraphText

Declaration

function Send: boolean;

Description

The Send method sends the GraphText values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the GraphText settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.GraphText.Send;


Add method

See also	Example

Applies to

GraphText

Declaration

function Add(GraphNumber: TCrGraphTextNumber): integer;

Type

TCrGraphTextNumber = integer;

Description

The Add method adds an item to the GraphText object and sets the internal index to that item.  It requires a Graph number as a parameter, which should be a number corresponding to a Graph in the Report.  Graphs are numbered starting from zero, from the top of the Report down, and left to right in each Section.  If the Add method is used, the steps to using GraphText are:

1. Add an item to the GraphText object (you must specify the Graph number).

2. Fill the item's properties (Title, SubTitle, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Graph numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the GraphText object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Graph number - must be same as in Report}

Crpe1.GraphText.Add(0);

{Section must also be specified when using Add}

Crpe1.GraphText.Section := 'PH';

Crpe1.GraphText.Title := 'Company Graph';

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

GraphText

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GraphText object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the GraphText object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the GraphText of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the GraphText properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.GraphText.Clear;

This code clears the GraphText properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.GraphText.Clear;

end;


Delete method

See also	Example

Applies to

GraphText

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the GraphText object.  The "nIndex" parameter represents the number of the item in the GraphText object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the GraphText object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Graph number - must be same as in Report}

Crpe1.GraphText.Add(0);

{Section must also be specified when using Add}

Crpe1.GraphText.Section := 'PH';

Crpe1.GraphText.Title := 'Company Graph';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.GraphText.Delete(0);


SectionAsCode property

See also	Example

Applies to

GraphText

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

Section

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The following example uses the SectionAsCode property to apply conditional changes to Graphs.  In this case, there is a Graph in each of three Group Header sections (GH1a, GH2a, GH3a).  Since the Section Code for GH1a is 3000, GH2a is 3001, and GH3a is 3002, it is possible to do a simple mathematical calculation on the remainder of the Section Code divided by 1000 to change the Title of the Graph only if it is not in GH1:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphText.Retrieve;

  for cnt := 0 to (Crpe1.GraphText.Count - 1) do

  begin

    {if the remainder of the SectionCode divided by 1000

     is greater than zero, then apply the change}

    if (Crpe1.GraphText[cnt].SectionAsCode mod 1000 > 0) then

      Crpe1.GraphText[cnt].Title := 'Sub-Group Graph';

  end;

end;


SectionType method

See also	Example

Applies to

GraphText

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1ac, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier.  See the Example for an illustration.


SectionType method - See also
Related

Section

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionType method - Example
Example

The following example uses the SectionType method to apply conditional changes to Graphs.  In this case, there is a Graph in each of three sections (RH, GH1a, GH2a).  Only the Graphs in the Group Headers should be changed, so the SectionType method can be used in an expression to apply the changes:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphText.Retrieve;

  for cnt := 0 to (Crpe1.GraphText.Count - 1) do

  begin

    {if the SectionType is GroupHeader, apply the change}

    if (Crpe1.GraphText[cnt].SectionType = 'GH') then

      Crpe1.GraphText[cnt].Title := 'Company Graph';

  end;

end;


CopyFrom method

See also	Example

Applies to

GraphText

Declaration

procedure CopyFrom(Source: TCrpeGraphText);

Description

The CopyFrom method copies the GraphText property values from another TCrpeGraphText object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the GraphText property values to a temporary TCrpeGraphText object:

var

tempGraphText : TCrpeGraphText;

begin

tempGraphText := TCrpeGraphText.Create;

tempGraphText.CopyFrom(Crpe1.GraphText);

{...later, when finished with the temp object...}

tempGraphText.Free;

end;


TitleFont property

See also	Example

Applies to

GraphText

Declaration

property TitleFont: TFont;

Description

The TitleFont property specifies the font for the main title text that will appear above the Graph.

Note

This feature is only available in Seagate Crystal Reports 7 or higher.


TitleFont property - See also
Related

Titles

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Fonts (SCR7+)

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TitleFont property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the Title font for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

begin

  Crpe1.GraphText[0].TitleFont.Name := 'Times New Roman';

  Crpe1.GraphText[0].TitleFont.Size := 16;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


SubTitleFont property

See also	Example

Applies to

GraphText

Declaration

property SubTitleFont: TFont;

Description

The SubTitleFont property specifies the font for the sub title text that will appear directly under the main Title.

Note

This feature is only available in Seagate Crystal Reports 7 or higher.


SubTitleFont property - See also
Related

Titles

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Fonts (SCR7+)

TitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SubTitleFont property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the SubTitle font for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

begin

  Crpe1.GraphText[0].SubTitleFont.Name := 'Times New Roman';

  Crpe1.GraphText[0].SubTitleFont.Size := 12;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


FootNoteFont property

See also	Example

Applies to

GraphText

Declaration

property FootNoteFont: TFont;

Description

The FootNoteFont property specifies the font for the footnote text of a Graph.

Note

This feature is only available in Seagate Crystal Reports 7 or higher.


FootNoteFont property - See also
Related

Titles

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Fonts (SCR7+)

TitleFont

SubTitleFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


FootNoteFont property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the FootNote font for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

begin

  Crpe1.GraphText[0].FootNoteFont.Name := 'Times New Roman';

  Crpe1.GraphText[0].FootNoteFont.Size := 8;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


GroupsTitleFont property

See also	Example

Applies to

GraphText

Declaration

property GroupsTitleFont: TFont;

Description

The GroupsTitleFont property specifies the font for the sub title text that will appear by the group axis.

Note

This feature is only available in Seagate Crystal Reports 7 or higher.


GroupsTitleFont property - See also
Related

Titles

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Fonts (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

DataTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupsTitleFont property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the GroupsTitle font for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

begin

  Crpe1.GraphText[0].GroupsTitleFont.Name := 'Times New Roman';

  Crpe1.GraphText[0].GroupsTitleFont.Size := 9;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


DataTitleFont property

See also	Example

Applies to

GraphText

Declaration

property DataTitleFont: TFont;

Description

The DataTitleFont property specifies the font for the sub title that appears by the data axis.

Note

This feature is only available in Seagate Crystal Reports 7 or higher.


DataTitleFont property - See also
Related

Titles

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Fonts (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

LegendFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DataTitleFont property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the DataTitle font for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

begin

  Crpe1.GraphText[0].DataTitleFont.Name := 'Times New Roman';

  Crpe1.GraphText[0].DataTitleFont.Size := 9;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


LegendFont property

See also	Example

Applies to

GraphText

Declaration

property LegendFont: TFont;

Description

The LegendFont property specifies the font for the graph Legend.  This setting will only be applicable if the Legend is visible (see GraphOptions.Legend).

Note

This feature is only available in Seagate Crystal Reports 7 or higher.


LegendFont property - See also
Related

Titles

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Fonts (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

GroupLabelsFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LegendFont property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the Legend font for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

begin

  Crpe1.GraphText[0].LegendFont.Name := 'Times New Roman';

  Crpe1.GraphText[0].LegendFont.Size := 8;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


GroupLabelsFont property

See also	Example

Applies to

GraphText

Declaration

property GroupLabelsFont: TFont;

Description

The GroupLabelsFont property specifies the font for the group axis of the graph.  On a vertical bar graph, this would be the horizontal axis.

Note

This feature is only available in Seagate Crystal Reports 7 or higher.


GroupLabelsFont property - See also
Related

Titles

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Fonts (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

DataLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupLabelsFont property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the GroupLabels font for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

begin

  Crpe1.GraphText[0].GroupLabelsFont.Name := 'Times New Roman';

  Crpe1.GraphText[0].GroupLabelsFont.Size := 8;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


DataLabelsFont property

See also	Example

Applies to

GraphText

Declaration

property DataLabelsFont: TFont;

Description

The DataLabelsFont property specifies the font for the data axis of the Graph.  On a vertical bar graph, this would be the vertical axis.

Note

This feature is only available in Seagate Crystal Reports 7 or higher.


DataLabelsFont property - See also
Related

Titles

Title

SubTitle

GroupsTitle

SeriesTitle

XAxisTitle

YAxisTitle

ZAxisTitle

FootNote

Fonts (SCR7+)

TitleFont

SubTitleFont

FootNoteFont

GroupsTitleFont

DataTitleFont

LegendFont

GroupLabelsFont

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DataLabelsFont property - Example
Example

The following example retrieves the GraphText information from the Report, then changes the DataLabels font for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphText.Retrieve;

if Crpe1.GraphText.Count > 0 then

begin

  Crpe1.GraphText[0].DataLabelsFont.Name := 'Times New Roman';

  Crpe1.GraphText[0].DataLabelsFont.Size := 8;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


GraphOptions

See also	Properties & Methods	Example

Declaration

property GraphOptions: TCrpeGraphOptions;

Type

TCrpeGraphOptions = class(TPersistent)

Description

The GraphOptions object contains all the properties and methods that relate to changing the features of the appearance of Graphs.

•	The Number property specifies the Graph Number, and can be used as a lookup value to point the GraphOptions object to a specific GraphOptions item.  See How Graphs are Numbered for more information on the numbering scheme.

•	The Section property specifies the section that the Graph is located in, and uses the "short" section naming convention used in the Crystal Reports Designer.  See "About Section Names" for more information.

•	The Retrieve method can be used to fill the GraphOptions object with information from the Report.

•	The Count property will indicate how many GraphOptions items are currently in the GraphOptions object.

•	The Item and ItemIndex properties can be used to navigate through the GraphOptions items in the GraphOptions object.

•	The Max property specifies the maximum value that will appear in the Graph. Any Graph values above this value are not charted.

•	The Min property specifies the minimum value that will appear in the Graph. Any Graph values below this value are not charted.

•	The DataValues property specifies whether or not to display the numeric value associated with each riser on the chart. If set to cTrue, a value appears in the Graph for each riser.

•	The GridLines property specifies whether or not to display Grid Lines on the Graph.

•	The BarDirection property specifies which way to display the bars in a Bar Graph: vertically or horizontally.

•	The Legend property specifies whether or not to display the Graph Legend.

•	The Font property specifies the Font for all text and values in the entire Graph.

•	The SectionAsCode property offers the ability to treat the Section name as a Section Code Number, which can be useful for doing mathematical expressions to filter out certain sections.

•	The SectionType method returns just the first characters of the Section name, so for GH1 (Group Header 1), the SectionType would be GH (Group Header).


GraphOptions - See also
Related

GraphData

GraphText

GraphType

How Graphs are Numbered

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GraphOptions - Properties & Methods
GraphOptions:

Properties & Methods

GraphOptions	TCrpe Component

Properties

BarDirection

DataValues

Font

GridLines

Legend

Max

Min

Key

Number

Location

Section

SectionAsCode

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


GraphOptions - Example
Example

This code sample shows how to retrieve the GraphOptions from a Report, then change various properties for the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

with Crpe1.GraphOptions do

begin

  Retrieve;

  Item[0];

  GridLines := cTrue;

  Font := 'Times New Roman';

  DataValues := cFalse;

  BarDirection := bdVertical;

  Legend := cTrue;

end;

Crpe1.Execute;


BarDirection property

See also	Example

Applies to

GraphOptions

Declaration

property BarDirection: TCrBarDirection;

Type

TCrBarDirection = (bdHorizontal, bdVertical, bdDefault);

Description

The BarDirection property specifies the direction of the bars in a Bar Graph.  These can be either vertical or horizontal.


BarDirection property - See also
Related

DataValues

Font

GridLines

Legend

Max

Min

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


BarDirection property - Example
Example

The following code illustrates the use of the GraphOptions BarDirection property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

if Crpe1.GraphOptions.Count > 0 then

  Crpe1.GraphOptions[0].BarDirection := bdHorizontal;

Crpe1.Output := toWindow;

Crpe1.Execute;


DataValues property

See also	Example

Applies to

GraphOptions

Declaration

property DataValues: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The DataValues property specifies whether or not the numeric value associated with each Riser on the Graph will be displayed.  If set to cTrue, a value appears in the Graph for each Riser.


DataValues property - See also
Related

BarDirection

Font

GridLines

Legend

Max

Min

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DataValues property - Example
Example

The following code illustrates the use of the GraphOptions DataValues property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

if Crpe1.GraphOptions.Count > 0 then

  Crpe1.GraphOptions[0].DataValues := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


Font property

See also	Example

Applies to

GraphOptions

Declaration

property Font: TFontName;

Description

The Font property specifies the font for all text and values in the Graph.  The property uses Delphi's TFontName type, which makes a list of installed fonts available on the Object Inspector (or if the property is double-clicked, the Font Dialog will appear).  It is limited to 128 characters in length (anything greater than that will be truncated).


Font property - See also
Related

BarDirection

DataValues

GridLines

Legend

Max

Min

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Font property - Example
Example

The following code illustrates the use of the GraphOptions Font property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

if Crpe1.GraphOptions.Count > 0 then

  Crpe1.GraphOptions[0].Font := 'Times New Roman';

Crpe1.Output := toWindow;

Crpe1.Execute;


GridLines property

See also	Example

Applies to

GraphOptions

Declaration

property GridLines: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The GridLines property specifies whether or not to display Grid Lines on the Graph.  If the property is set to cTrue, Grid Lines will be visible.


GridLines property - See also
Related

BarDirection

DataValues

Font

Legend

Max

Min

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GridLines property - Example
Example

The following code illustrates the use of the GraphOptions GridLines property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

if Crpe1.GraphOptions.Count > 0 then

  Crpe1.GraphOptions[0].GridLines := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


Item property

See also	Example

Applies to

GraphOptions

Declaration

property Item[const nIndex: integer]: TCrpeGraphOptions;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the GraphOptions object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  GraphOptions[2] is the same as GraphOptions.Item[2].

•	Item returns a reference to the GraphOptions object, so the GraphOptions properties can be used right after the subscript: GraphOptions[2].Min := 2000;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

{Set GraphOptions object to the 2nd graph}

Crpe1.GraphOptions.Item[1];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

{Set GraphOptions object to the 2nd graph}

Crpe1.GraphOptions[1];


ItemIndex property

See also	Example

Applies to

GraphOptions

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GraphOptions item number, or set the GraphOptions object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (GraphOptions[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the GraphOptions object is pointing to the first GraphOptions item:

if Crpe1.GraphOptions.ItemIndex <> 0 then

  Crpe1.GraphOptions[0];


Legend property

See also	Example

Applies to

GraphOptions

Declaration

property Legend: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The Legend property specifies whether or not to display the Graph Legend.  If the property is set to cTrue, the Legend will be visible.


Legend property - See also
Related

BarDirection

DataValues

Font

GridLines

Max

Min

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Legend property - Example
Example

The following code illustrates the use of the GraphOptions Legend property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

if Crpe1.GraphOptions.Count > 0 then

  Crpe1.GraphOptions[0].Legend := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


Max property

See also	Example

Applies to

GraphOptions

Declaration

property Max: double;

Description

The Max property specifies the maximum value that will appear in the graph.  Any Graph values above this value are not charted.


Max property - See also
Related

BarDirection

DataValues

Font

GridLines

Legend

Min

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Max property - Example
Example

The following code illustrates the use of the GraphOptions Max property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

if Crpe1.GraphOptions.Count > 0 then

  Crpe1.GraphOptions[0].Max := 144000;

Crpe1.Output := toWindow;

Crpe1.Execute;


Min property

See also	Example

Applies to

GraphOptions

Declaration

property Min: double;

Description

The Min property specifies the minimum value that will appear in the Graph.  Any Graph values below this value are not charted.


Min property - See also
Related

BarDirection

DataValues

Font

GridLines

Legend

Max

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Min property - Example
Example

The following code illustrates the use of the GraphOptions Min property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

if Crpe1.GraphOptions.Count > 0 then

  Crpe1.GraphOptions[0].Min := 40;

Crpe1.Output := toWindow;

Crpe1.Execute;


Number property

See also	Example

Applies to

GraphOptions

Declaration

property Number: TCrGraphOptionsNumber;

Type

TCrGraphOptionsNumber = integer;

Description

The Number property specifies the Graph Number.

•	If the Retrieve method is used to fill the GraphOptions object with infomation from the Report, each GraphOptions item will have a unique Graph Number assigned by the VCL.

•	If the manual Add method is used instead, a Graph number will have to be specifed which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered).

The primary use of the Number property is as a look-up to point the GraphOptions object to the item with the Graph number specified.  The default array property, Item, however, provides an easier way to navigate through the object.


Number property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

The following code illustrates the use of the Number property to navigate the GraphOptions object to the specific item that has a Number value of 1:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

{Set GraphOptions to item with Number value of 1}

Crpe1.GraphOptions.Number = 1;

Crpe1.GraphOptions.BarDirection := bdHorizontal;

Crpe1.Output := toWindow;

Crpe1.Execute;


Section property

See also	Example

Applies to

GraphOptions

Declaration

property Section: string;

Description

The Section property contains the Section name of the item that the GraphOptions object is currently pointed to.  It indicates in which Section of the Report that the Graph is located.

Note that you cannot move a Graph from one Section to another by changing this property.  It should primarily be used as a read-only property after the GraphOptions information has been retrieved with the Retrieve method.  If the manual Add method is used to add items to the GraphOptions object, then Section will have to be assigned the correct  value in code.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections.  Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.


Section property - See also
Related

SectionAsCode

SectionType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Section property - Example
Example

In the following example, the Section property is used to apply changes only to Graphs which exist in a given Report Section (Page Header in this case):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

for cnt := 0 to (Crpe1.GraphOptions.Count - 1) do

begin

  if Crpe1.GraphOptions[cnt].Section = 'PH' then

    Crpe1.GraphOptions[cnt].BarDirection := bdHorizontal;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

GraphOptions

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the GraphOptions object, and does not need to be called in code.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

GraphOptions

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

GraphOptions

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the GraphOptions object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphOptions.Retrieve;

  for cnt := 0 to (Crpe1.GraphOptions.Count - 1) do

    Crpe1.GraphOptions[cnt].GridLines := cTrue;

end;


Retrieve method

See also	Example

Applies to

GraphOptions

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the GraphOptions information from the Report and stores it in the GraphOptions object.  If no GraphOptions information was found, the call returns False.  Be aware that calling Retrieve will first cause the GraphOptions object to be cleared, so any current information stored in it will be removed.

Note

Since the GraphOptions object also applies to Subreports, the Retrieve method will obtain the GraphOptions for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the GraphOptions information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate GraphOptions information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptions.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.GraphOptions.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

GraphOptions

Declaration

function Send: boolean;

Description

The Send method sends the GraphOptions values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the GraphOptions settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.GraphOptions.Send;


Add method

See also	Example

Applies to

GraphOptions

Declaration

function Add(GraphNumber: TCrGraphOptionsNumber): integer;

Type

TCrGraphOptionsNumber = integer;

Description

The Add method adds an item to the GraphOptions object and sets the internal index to that item.  It requires a Graph number as a parameter, which should be a number corresponding to a Graph in the Report.  Graphs are numbered starting from zero, from the top of the Report down, and left to right in each Section.  If the Add method is used, the steps to using GraphOptions are:

1. Add an item to the GraphOptions object (you must specify the Graph number).

2. Fill the item's properties (BarDirection, DataValues, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Graph numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the GraphOptions object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Graph number - must be same as in Report}

Crpe1.GraphOptions.Add(0);

{Section must also be specified when using Add}

Crpe1.GraphOptions.Section := 'PH';

Crpe1.GraphOptions.Font := 'Times New Roman';

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

GraphOptions

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GraphOptions object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the GraphOptions object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the GraphOptions of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the GraphOptions properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.GraphOptions.Clear;

This code clears the GraphOptions properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.GraphOptions.Clear;

end;


Delete method

See also	Example

Applies to

GraphOptions

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the GraphOptions object.  The "nIndex" parameter represents the number of the item in the GraphOptions object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the GraphOptions object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Graph number - must be same as in Report}

Crpe1.GraphOptions.Add(0);

{Section must also be specified when using Add}

Crpe1.GraphOptions.Section := 'PH';

Crpe1.GraphOptions.Font := 'Times New Roman';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.GraphOptions.Delete(0);


SectionAsCode property

See also	Example

Applies to

GraphOptions

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

Section

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The following example uses the SectionAsCode property to apply conditional changes to Graphs.  In this case, there is a Graph in each of three Group Header sections (GH1a, GH2a, GH3a).  Since the Section Code for GH1a is 3000, GH2a is 3001, and GH3a is 3002, it is possible to do a simple mathematical calculation on the remainder of the Section Code divided by 1000 to change the options of the Graph only if it is not in GH1:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphOptions.Retrieve;

  for cnt := 0 to (Crpe1.GraphOptions.Count - 1) do

  begin

    {if the remainder of the SectionCode divided by 1000

     is greater than zero, then apply the change}

    if (Crpe1.GraphOptions[cnt].SectionAsCode mod 1000 > 0) then

      Crpe1.GraphOptions[cnt].GridLines := cTrue;

  end;

end;


SectionType method

See also	Example

Applies to

GraphOptions

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1ac, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier.  See the Example for an illustration.


SectionType method - See also
Related

Section

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionType method - Example
Example

The following example uses the SectionType method to apply conditional changes to Graphs.  In this case, there is a Graph in each of three sections (RH, GH1a, GH2a).  Only the Graphs in the Group Headers should be changed, so the SectionType method can be used in an expression to apply the changes:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphOptions.Retrieve;

  for cnt := 0 to (Crpe1.GraphOptions.Count - 1) do

  begin

    {If SectionType is GroupHeader, apply the change}

    if (Crpe1.GraphOptions[cnt].SectionType = 'GH') then

      Crpe1.GraphOptions[cnt].Legend := cTrue;

  end;

end;


CopyFrom method

See also	Example

Applies to

GraphOptions

Declaration

procedure CopyFrom(Source: TCrpeGraphOptions);

Description

The CopyFrom method copies the GraphOptions property values from another TCrpeGraphOptions object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the GraphOptions property values to a temporary TCrpeGraphOptions object:

var

tempGraphOptions : TCrpeGraphOptions;

begin

tempGraphOptions := TCrpeGraphOptions.Create;

tempGraphOptions.CopyFrom(Crpe1.GraphOptions);

{...later, when finished with the temp object...}

tempGraphOptions.Free;

end;


Subreports

See also	Properties & Methods	Example

Declaration

property Subreports: TCrpeSubreports;

Type

TCrpeSubreports = class(TPersistent)

Description

Many of the properties and sub-class objects on the VCL can apply to the main Report, or any Subreports as well.  When Subreports are involved, the Subreports object is used to distinguish which Report the VCL properties are currently pointing to.  Since the first item in the Subreports object (Subreports[0]) is always a reference to the main Report, the Subreports object should probably have been called Reports, but for now, just bear in mind that Subreports[0] actually refers to the main Report.

•	The Subreports object maintains a list of Report names, including the Main Report, and any associated Subreports, via the Name property.

•	The associated section the Subreports are located in is available via the Section property.

•	The Subreports object can be filled automatically, by using Retrieve, or it can be filled/emptied manually using the Add and Delete methods.  Note that Retrieve will not retrieve all of the information about a Report, such as Formulas, Tables, etc.  Retrieve for the Subreports object simply gathers the Subreport names and sections, opens a printjob for each Subreport, and creates sub-class objects (Formulas, Tables, etc.) for each Subreport.  These sub-class objects still need to have their information retrieved using their own Retrieve methods.

•	The Count method returns the number of items in the Subreports object, and includes the Main Report.

•	The Clear method is used to remove the Subreport information, which includes the information set for the main Report as well.

•	Navigating through the Subreports can be accomplished via the default array property: Item, the ItemIndex property, or the Name property.  Since Item is a default array index property, it does not need to be specified when making the call:  Subreports[1] sets the Crystal component to the first Subreport.

•	The SubExecute property determines whether Subreports can be run as stand-alone Reports or not.  If it is set to True, and the Subreports object is pointing to a Subreport when the Execute method is called, the Subreport will run instead of the main Report.

•	The NLinks and OnDemand properties are new to SCR 7.  They are read-only properties which give further information about the Subreport.

Important Note

It is important to remember that the Subreports object affects almost every other property in the Crystal component.  If the Subreports object is changed from the main Report (Subreports[0]) to a Subreport (Subreports[1]), then all of the properties that can apply to Subreports will now be pointing to that Subreport also.

Syntax Note

Previously, the Subreports item had to be set first, and then the Report property applying to that Subreport, as in this example:

Crpe1.Subreports[2];

Crpe1.SortFields[3].Field := '{company.STATE}';

This has now changed, and the Subreports class now supports the following style of syntax, which is more efficient:

Crpe1.Subreports[2].SortFields[3].Field := '{company.STATE}';


Subreports - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Subreports - Properties & Methods
Subreports:

Properties & Methods

Subreports	TCrpe Component

Properties

NLinks

OnDemand

Section

SubExecute

Key

Name

Navigation

ItemIndex

Item

Methods

Clear

CopyFrom

Count

IndexOf

Retrieve

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


Subreports - Example
Example

To obtain the names of the Subreports, read the Name property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  ListBox1.Items.Add(Crpe1.Subreports.Name);

This example shows how to set properties on the main Report and first Subreport, and then run the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Subreports}

Crpe1.Subreports.Retrieve;

{Retrieve the main Report Tables}

Crpe1.Tables.Retrieve;

{Set the Path for the first Table}

Crpe1.Tables[0].Path := 'C:\Reports\';

{Propagate Path for all main & sub tables}

Crpe1.Tables.Propagate := True;

{Point to first Subreport}

Crpe1.Subreports[1];

{Set Subreport Selection Formula}

Crpe1.Selection.Formula.Text := '{company.STATE} = "CA"';

{Set Output}

Crpe1.Output := toWindow;

{Run the Report - As long as the Subreports.SubExecute

 is set to False, the main Report will run on Execute,

 regardless of which Subreport is currently selected}

Crpe1.Execute;


Item property

See also	Example

Applies to

Subreports

Declaration

property Item[nIndex: integer]: TCrpeSubreports;

Description

The Item property is a default array property.  It's primary use is to navigate through the Subreport object, allowing it to be treated as an array.

•	Item is the default property, so it does not need to be specified, therefore this: Subreports.Item[2], is the same as this: Subreports[2].  Both will point the properties of the Subreports object to the second Subreport.

•	Item returns a reference to the Subreports object, so the Subreports properties can be used right after the subscript: ShowMessage(Subreports[2].Section);


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

{Set Subreports object to the 2nd subreport}

Crpe1.Subreports.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

{Set Subreports object to the 2nd subreport}

Crpe1.Subreports[2];


ItemIndex property

See also	Example

Applies to

Subreports

Declaration

property ItemIndex: integer;

Description

The ItemIndex property can be used to set the current Subreport, or to read which item the Subreport object is currently set to.  For example, this code sets the current Subreport to the first Subreport:

Crpe1.SubReports.ItemIndex := 1;

And this code shows which Subreport number is currently being accessed by the Subreports object:

ShowMessage(IntToStr(Crpe1.Subreports.ItemIndex));


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the Subreports object is pointing to the main Report:

if Crpe1.Subreports.ItemIndex <> 0 then

  Crpe1.Subreports[0];


Name property

See also	Example

Applies to

Subreports

Declaration

property Name: TCrSubreportName;

Type

TCrSubreportName = string;

Description

The Name property is the key property for the Subreports sub-class.  It contains the Name of the Report/Subreport.  For the main Report, this property contains an empty string.  It is a look-up property and therefore primarily serves to provide a way to navigate through the Subreports items by specifying a Subreport Name.  However, in most cases it will be easier to navigate using the default Item or the ItemIndex properties.

When the Name property is assigned a new value, those properties and sub-classes on the Crystal VCL that can apply to Subreports (such as Selection, GroupSelection, SectionFormat, SQLQuery, etc.), will be updated to look at the particular Subreport specified.

•	If the Retrieve method is used, the Name property is automatically filled for each Subreports item that is retrieved.

•	The Add and Delete methods provide a manual method of adding/removing items from the Subreports object in place of Retrieve/Clear.


Name property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Name property - Example
Example

The following code fills a list box with all the Subreport Names (we start the count with 1 to avoid the Main Report):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

  ListBox1.Items.Add(Crpe1.Subreports[cnt].Name);

The following code shows how to use the Name property to cause the Subreports object to point to the main Report, after accessing a Subreport:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

Crpe1.Subreports[1];

Crpe1.Tables.Retrieve;

Crpe1.Tables[0].Name := 'sales.dbf';

{This line points the VCL back to the main Report}

Crpe1.Subreports.Name := '';

Note that in the above example, the same effect can be achieved by this:

{This line points the VCL back to the main Report}

Crpe1.Subreports[0];


Section property

See also	Example

Applies to

Subreports

Declaration

property Section: string;

Description

The Section property contains the Section name that the current Subreport is located in.  For the main Report, this property will be a blank string.  It's primary use is to help locate Subreports in a Report, since there is no easy way in the Crystal Reports designer to determine where all the Subreports are located.

If the Retrieve method is used, the Section property is automatically filled when the Subreports are retrieved.  The Section property is not used in the internal processing of the VCL so assigning it an new value will not affect the execution of the Report (ie. it is not possible to move a Subreport to a different section by assigning a new value to the Section property).

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer.  See About Section Names for more details on the syntax.


Section property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Section property - Example
Example

The following code fills a list box with all the Subreport Section codes:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

  ListBox1.Items.Add(Crpe1.Subreports[cnt].Section);


SubExecute property

See also	Example

Applies to

Subreports

Declaration

property SubExecute: boolean;

Description

The SubExecute property determines whether Subreports can be run as individual reports or not.  By default this property is set to False.

If the SubExecute property is set to True, then when Crpe1.Execute is called, the current Report will be run.  The current Report is the Report that the Subreports object is currently pointing to (whatever was last specified via the Item, ItemIndex, or Name properties).  If this happens to be a Subreport, then the Subreport will run as if it were a stand-alone Report.

If the SubExecute property is set to False, then when Crpe1.Execute is called, the main Report will always be run (along with any associated Subreports), regardless of which Report the Subreports object is currently pointing to.

Bear in mind that if you set this property to True, and you want to run the main Report, you will need to make sure that the Subreports object is pointing to the main Report before calling Crpe1.Execute, ie:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

Crpe1.SubReports[1];      {pointing to Subreport 1}

Crpe1.SubExecute := True;

Crpe1.SubReports[0];	{point to Main Report before Executing}

Crpe1.Execute;	{Run the Main Report}


SubExecute property - See also
Related

Name

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SubExecute property - Example
Example

The following example will run the first Subreport as a separate Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

Crpe1.Subreports[1];

Crpe1.Subreports.SubExecute := True;

Crpe1.Output := toWindow;

Crpe1.Execute;

The following example will run the main Report in spite of the fact that the Crystal Reports Component is currently pointing to a Subreport:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

Crpe1.Subreports[1];

Crpe1.Subreports.SubExecute := False;

Crpe1.Execute;


Create method

See also

Applies to

Subreports

Declaration

constructor Create;

Description

The Create constructor creates the Subreports object.  It is used internally in the VCL component to create the Subreports object and should not be called outside of the component.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

Subreports

Declaration

destructor Destroy; override;

Description

The Destroy method frees the Subreports object.  It is used internally in the VCL component to destroy the Subreports object and should not be called outside of the component.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method

See also	Example

Applies to

Subreports

Declaration

function Count: integer;

Description

Count returns the number of Subreports.  It includes the Main Report, and so a Count value of 1 means that there is only one main Report and no Subreports.  Likewise, Subreports[0] refers to the main Report.  When dealing with Subreports, be sure to call the Retrieve method before using Count.  This will ensure a meaningful value.


Count method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The following code fills a list box with all the Subreport Names.  The count is started with 1 since 0 refers to the main Report:

Crpe1.Subreports.Retrieve;

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt1];

  ListBox1.Items.Add(Crpe1.Subreports.Name);

end;


Retrieve method

See also	Example

Applies to

Subreports

Declaration

function Retrieve: boolean;

Description

Retrieve obtains Subreport information from a Report.  It returns True if the call was successful, and False if it did not find any Subreports.  Retrieve will get the Name, and Section of each Subreport, and allocate memory to store further Subreport details.  It does not retrieve everything about a Subreport, such as Selection Formula, Section Information, Table information, etc.  These must all be retrieved individually using their associated objects.

If you intend to work with Subreports, then this method is the first one that should be called.  After calling it, a loop can be set up which will go through all the Reports and retrieve the desired data from each one (see Example).

Note

Retrieve will clear out any current Subreport information, so it should not be called more than once during the process of running a Report.


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for obtaining Subreport items, and then looping through the Subreports to retrieve other information:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.Tables.Retrieve;

    Crpe1.Selection.Retrieve;

    Crpe1.SortFields.Retrieve;

    Crpe1.GraphType.Retrieve;

  end;

end;


Add method

See also	Example

Applies to

Subreports

Declaration

function Add(SubName: TCrSubreportName): integer;

Types

TCrSubreportName = string;

Description

The Add and Delete methods provide a manual method of maintaining the Subreport items in the Subreports object.  We recommend that you use the Retrieve method instead as it is much easier and less error-prone.

•	The Add method adds an item to the Subreports object and sets the Subreports object index to that item.

•	It requires a valid Subreport name as a parameter.

•	The Subreport Name is limited to 128 characters in length (anything longer than that will be truncated).

Note

This method will not add a Subreport to a Report; it only works on the VCL's internal data arrays.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

This example adds a new Subreport called MySubName to the Subreports object, and then runs the Subreport:

Crpe1.ReportName := 'C:\Report1.rpt';

{Specify Subreport Name - must be same as in Report}

Crpe1.Subreports.Add('SubRpt1');

Crpe1.Subreports.SubExecute := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

Subreports

Declaration

procedure Clear;

Description

The Clear procedure removes any current Subreport information from the VCL.  It does not clear the main Report information.  To Clear the main Report as well, use the CloseJob method of the TCrpe object:

Crpe1.CloseJob;

or change the ReportName property to a different value (which causes CloseJob to be called):

Crpe1.ReportName := 'C:\aNewReport.rpt';

To Clear the main Report and Subreport information, and all of the Window/Printer/Export properties as well, use the Clear method of the TCrpe component:

Crpe1.Clear;

Note

It is not normally necessary to call the Subreports Clear method, since this will be called automatically when the ReportName is changed.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code sets the Subreport Selection Formula, runs the main Report, and then clears all the Subreport information stored in the VCL component:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

Crpe1.Subreports[1];

Crpe1.Selection.Formula.Text := '{company.STATE} = "CA"';

Crpe1.Subreports[0];

Crpe1.Output := toWindow;

Crpe1.Execute;

{Clear the Subreport information from the VCL}

Crpe1.Subreports.Clear;

To clear properties for a specific Subreport only, use the Clear methods for those particular properties.  This example clears the Tables object for the second Subreport:

Crpe1.Subreports[2];

Crpe1.Tables.Clear;


Delete method

See also	Example

Applies to

Subreports

Declaration

procedure Delete(nIndex: integer);

Description

The Add and Delete methods provide a manual method of maintaining the Subreport items in the Subreports object of the VCL.  We recommend that you use the Retrieve method instead as it is much easier and less error-prone.  The Delete method removes an item from the Subreports object.  If that item was the currently selected one, it sets the Subreports index to the previous item.  It requires a valid Subreport item number as a parameter.

This method will not remove a Subreport from a Report; it only works on the VCL's internal data arrays.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

This example adds a new Subreport called 'SubRpt1' to the Subreports object, runs the Subreport, and then finally deletes the Subreport item from the Subreports object:

Crpe1.ReportName := 'C:\Report1.rpt';

{Specify Subreport Name - must be same as in Report}

Crpe1.Subreports.Add('SubRpt1');

Crpe1.Subreports.SubExecute := True;

Crpe1.Output := toWindow;

Crpe1.Execute;

{Delete the Subreport item from the VCL}

Crpe1.Subreports.Delete(1);


IndexOf method

See also	Example

Applies to

Subreports

Declaration

function IndexOf(SubName: TCrSubreportName): integer;

Type

TCrSubreportName = string[128];

Description

The IndexOf method takes a Subreport name and returns the index position of the Subreport item in the current Subreports object.

After the Retrieve method has been called, the Subreports object contains one item for each Subreport in the Report.  The IndexOf method can be used to determine if a given Subreport Name actually exists in the Subreports object before trying to access it.


IndexOf method - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

The following code illustrates the use of the IndexOf method to locate a specific Subreport item by it's name:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

{Find a specific Subreport}

nItem := Crpe1.Subreports.IndexOf('SubreportOne');

{If it exists, retrieve the Formulas for that Subreport}

if nItem > -1 then

begin

with Crpe1.Subreports[nItem] do

  Formulas.Retrieve;

end;

end;


NLinks property

See also	Example

Applies to

Subreports

Declaration

property NLinks: integer;

Description

The NLinks property is a read-only property that reveals the number of Subreport Links that are active for the current Subreport.

A Subreport that is linked to the main Report will accept a value from the main Report and select the Records for that Subreport based on the value passed in from the main Report.  Linked Subreports are normally used in the Details or Group Header/Footer areas of a Report, to add or arrange specific details for a particular record or group in the main Report.  In this way, it is possible to format the details in the Subreport independant of the formatting of the main Report.


NLinks property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NLinks property - Example
Example

The following code checks the NLinks property of a Subreport:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

ShowMessage('Subreport 1 has :' +

  IntToStr(Crpe1.Subreports[1].NLinks) + ' Links');


OnDemand property

See also	Example

Applies to

Subreports

Declaration

property OnDemand: boolean;

Description

The OnDemand property is a read-only property that reveals whether the current Subreport is set to be "On Demand" or not.  For further details about "On Demand" Subreports, consult the Seagate Crystal Reports Help File.


OnDemand property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnDemand property - Example
Example

The following code checks the OnDemand property of a Subreport:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Subreports.Retrieve;

if Crpe1.Subreports[1].OnDemand then

  ShowMessage('Subreport 1 is OnDemand');


CopyFrom method

See also	Example

Applies to

Subreports

Declaration

procedure CopyFrom(Source: TCrpeSubreports);

Description

The CopyFrom method copies the Subreports sub-class property values to another TCrpeSubreports object.  It is similar to Delphi's Assign method.  It is useful for temporary storage of values.

Note

This method will not copy all of the other sub-classes of information relating to a particular Subreport, such as Selection, Tables, SortFields, etc.  These must be done separately, or via the CopyFrom method for the base TCrpe class.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Subreports property values to a temporary TCrpeSubreports object:

var

tempSubreports : TCrpeSubreports;

begin

tempSubreports := TCrpeSubreports.Create;

tempSubreports.CopyFrom(Crpe1.Subreports);

{...later, when finished with the temp object...}

tempSubreports.Free;

end;


AreaFormatFormulas

See also	Properties & Methods	Example

Declaration

property AreaFormatFormulas: TCrpeAreaFormatFormulas;

Type

TCrpeAreaFormatFormulas = class(TPersistent)

Description

AreaFormatFormulas encapsulates the formula control over Area Formatting that is available in the Format Section dialog of Crystal Reports designer.  Whereas the Format Section dialog in Crystal Reports contains both Sections and Areas, in the VCL these are separated.  Sections are controlled by SectionFormat and SectionFormatFormulas; Areas are controlled by AreaFormat and AreaFormatFormulas.

The difference between an Area and a Section is that Sections are subdivisions of a given area.  For instance, for any Group in a Report, there can only be one Group Header and one Group Footer.  These are called Areas.  But the Group Header can be subdivided into numerous parts (GH1a, GH1b, etc.).  These subdivisions constitute Sections.  The AreaFormat and AreaFormatFormula properties apply to all the Sections in an Area, whereas the SectionFormat and SectionFormatFormulas apply only to a particular subsection of an Area.

Again, AreaFormatFormulas apply formula control to the general areas of a Report (Report Header, Group Header 1, Details, etc.), whereas SectionFormatFormulas apply formula control to the specific sections (Report Header a, Group Header 2b, Details c, etc.).

The Section naming format has been adopted from the Crystal Reports "short" section naming convention, so RH means ReportHeader, GH3 means GroupHeader 3, etc.  See "About Section Names" for more information.

•	The Section property specifies which Report Area the AreaFormatFormulas will apply to.

•	The Retrieve method can be used to get the AreaFormatFormulas information from the Report.

•	The Count method returns the number of items currently contained in the AreaFormatFormulas object.

•	The Item, and ItemIndex properties can be used to navigate through the different Section items in the AreaFormat object.

Limitations

AreaFormatFormulas has certain limitations similar to those of AreaFormat:

•	For Report Header (RH) areas, the NewPageBefore formula does not apply.

•	For Report Footer (RF) areas, the NewPageAfter formula does not apply.

•	For Page Header (PH) and Page Footer (PF) areas, the following formulas do not apply:

Hide

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

Any values assigned to the formulas for these areas will be ignored when the Report is run.


AreaFormatFormulas - See also
Related

SectionFormatFormulas

AreaFormat

SectionFormat

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AreaFormatFormulas - Properties & Methods
AreaFormatFormulas:

Properties & Methods

AreaFormatFormulas	TCrpe Component

Properties

Hide

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

Key

Section

SectionAsCode

Navigation

ItemIndex

Item

Methods

Clear

CopyFrom

Count

IndexOf

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


AreaFormatFormulas - Example
Example

This example retrieves the AreaFormatFormula information, then assigns a Suppress formula to the Details area, so that the Details area will be suppressed if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Loop through the Areas}

for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.AreaFormatFormulas[cnt].Section = 'D' then

  begin

    {Clear the Suppress formula}

    Crpe1.AreaFormatFormulas[cnt].Suppress.Clear;

    {Add the new formula}

    Crpe1.AreaFormatFormulas[cnt].Suppress.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


Section property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property Section: TCrAreaFormatFormulasSection;

Type

TCrAreaFormatFormulasSection = string;

Description

The Section property specifies the Section name that the AreaFormatFormulas object is currently pointed to.  The property acts as a look-up, to point the AreaFormatFormulas object to the item with the Section specified.

If the Retrieve method is used, the Section property is automatically filled when the AreaFormatFormulas  are retrieved.  The IndexOf method can be used to locate an AreaFormatFormula item with a specific Section name.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.

Note

Whereas objects such as SectionFormat and SectionFormatFormulas work on specific individual sub-sections, such as Details "a", Details "b", etc., AreaFormat and AreaFormatFormulas work on certain areas, for example, Details area.  The options set in these objects affect all the sub-sections of that Area as a unit.


Section property - See also
Related

IndexOf

SectionAsCode

SectionType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Section property - Example
Example

This example retrieves the AreaFormatFormula information, then assigns a Suppress formula to the Details area, so that the Details area will be suppressed if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Loop through the Areas}

for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.AreaFormatFormulas[cnt].Section = 'D' then

  begin

    {Clear the Suppress formula}

    Crpe1.AreaFormatFormulas[cnt].Suppress.Clear;

    {Add the new formula}

    Crpe1.AreaFormatFormulas[cnt].Suppress.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


Hide property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property Hide: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The Hide property is a stringlist that contains the Formula used to control the Hide option of the area formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Hide (Drill-Down OK)" item in the Format | Section dialog of Crystal Reports Designer.

•	The Hide formula must have a boolean result, since it is controlling whether the area will be suppressed or not (ie. True or False).

•	To clear an AreaFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the Hide Formula for the 4th Area}

Crpe1.AreaFormatFormulas[4].Hide.Text := CrEmptyStr;

•	Any values in the AreaFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.AreaFormatFormulas[4].Hide.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.

Limitations

This formula does not apply to Page Header and Page Footer areas.


Hide property - See also
Related

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Hide property - Example
Example

This example retrieves the AreaFormatFormula information, then assigns a Hide formula to the Details area, so that the Details area will be hidden if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Loop through the Areas}

for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.AreaFormatFormulas[cnt].Section = 'D' then

  begin

    {Clear the Hide formula}

    Crpe1.AreaFormatFormulas[cnt].Hide.Clear;

    {Add the new formula}

    Crpe1.AreaFormatFormulas[cnt].Hide.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


KeepTogether property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property KeepTogether: TCrpeString

Type

TCrpeString = class(TStringList)

Description

The KeepTogether property is a stringlist that contains the Formula used to control the KeepTogether option of the area formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Keep Together" item in the Format | Section dialog of Crystal Reports Designer.

•	The KeepTogether formula must have a boolean result.

•	To clear an AreaFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the KeepTogether Formula for the 4th Area}

Crpe1.AreaFormatFormulas[4].KeepTogether.Text := CrEmptyStr;

•	Any values in the AreaFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.AreaFormatFormulas[4].KeepTogether.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.

Limitations

This formula does not apply to Page Header or Page Footer areas.


KeepTogether property - See also
Related

Hide

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


KeepTogether property - Example
Example

This example retrieves the AreaFormatFormula information, then assigns a KeepTogether formula to the Details area, so that the Details area will stay together if the State is California (that is, a record will not be split over two pages):

Crpe1.ReportName := 'Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Loop through the Areas}

for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.AreaFormatFormulas[cnt].Section = 'D' then

  begin

    {Clear the KeepTogether formula}

    Crpe1.AreaFormatFormulas[cnt].KeepTogether.Clear;

    {Add the new formula}

    Crpe1.AreaFormatFormulas[cnt].KeepTogether.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


NewPageAfter property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property NewPageAfter: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The NewPageAfter property is a stringlist that contains the Formula used to control the NewPageAfter option of the area formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "New Page After" item in the Format | Section dialog of Crystal Reports Designer.

•	The NewPageAfter formula must have a boolean result.

•	To clear an AreaFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the NewPageAfter Formula for the 4th Area}

Crpe1.AreaFormatFormulas[4].NewPageAfter.Text := CrEmptyStr;

•	Any values in the AreaFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.AreaFormatFormulas[4].NewPageAfter.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.

Limitations

This formula does not apply to Report Footer, Page Header, or Page Footer areas.


NewPageAfter property - See also
Related

Hide

KeepTogether

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NewPageAfter property - Example
Example

This example retrieves the AreaFormatFormula information, then assigns a NewPageAfter formula to the Details area, so that the a Page Break will follow the Details area if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Loop through the Areas}

for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.AreaFormatFormulas[cnt].Section = 'D' then

  begin

    {Clear the NewPageAfter formula}

    Crpe1.AreaFormatFormulas[cnt].NewPageAfter.Clear;

    {Add the new formula}

    Crpe1.AreaFormatFormulas[cnt].NewPageAfter.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


NewPageBefore property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property NewPageBefore: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The NewPageBefore property is a stringlist that contains the Formula used to control the NewPageBefore option of the area formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "New Page Before" item in the Format | Section dialog of Crystal Reports Designer.

•	The NewPageBefore formula must have a boolean result.

•	To clear an AreaFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the NewPageBefore Formula for the 4th Area}

Crpe1.AreaFormatFormulas[4].NewPageBefore.Text := CrEmptyStr;

•	Any values in the AreaFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.AreaFormatFormulas[4].NewPageBefore.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.

Limitations

This formula does not apply to Report Header, Page Header, or Page Footer areas.


NewPageBefore property - See also
Related

Hide

KeepTogether

NewPageAfter

PrintAtBottomOfPage

ResetPageNAfter

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NewPageBefore property - Example
Example

This example retrieves the AreaFormatFormula information, then assigns a NewPageBefore formula to the Details area, so that the a Page Break will occur before the Details area if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Loop through the Areas}

for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.AreaFormatFormulas[cnt].Section = 'D' then

  begin

    {Clear the NewPageBefore formula}

    Crpe1.AreaFormatFormulas[cnt].NewPageBefore.Clear;

    {Add the new formula}

    Crpe1.AreaFormatFormulas[cnt].NewPageBefore.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


PrintAtBottomOfPage property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property PrintAtBottomOfPage: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The PrintAtBottomOfPage property is a stringlist that contains the Formula used to control the PrintAtBottomOfPage option of the area formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Print at Bottom of Page" item in the Format | Section dialog of Crystal Reports Designer.

•	The PrintAtBottomOfPage formula must have a boolean result.

•	To clear an AreaFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the PrintAtBottomOfPage Formula for the 4th Area}

Crpe1.AreaFormatFormulas[4].PrintAtBottomOfPage.Text := CrEmptyStr;

•	Any values in the AreaFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.AreaFormatFormulas[4].PrintAtBottomOfPage.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.

Limitations

This formula does not apply to Page Header or Page Footer areas.


PrintAtBottomOfPage property - See also
Related

Hide

KeepTogether

NewPageAfter

NewPageBefore

ResetPageNAfter

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintAtBottomOfPage property - Example
Example

This example retrieves the AreaFormatFormula information, then assigns a PrintAtBottomOfPage formula to the Details area, so that the Details area will be printed at the bottom of the page if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Loop through the Areas}

for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.AreaFormatFormulas[cnt].Section = 'D' then

  begin

    {Clear the PrintAtBottomOfPage formula}

    Crpe1.AreaFormatFormulas[cnt].PrintAtBottomOfPage.Clear;

    {Add the new formula}

    Crpe1.AreaFormatFormulas[cnt].PrintAtBottomOfPage.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


ResetPageNAfter property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property ResetPageNAfter: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The ResetPageNAfter property is a stringlist that contains the Formula used to control the ResetPageNAfter option of the area formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Reset Page Number After" item in the Format | Section dialog of Crystal Reports Designer.

•	The ResetPageNAfter formula must have a boolean result.

•	To clear an AreaFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the ResetPageNAfter Formula for the 4th Area}

Crpe1.AreaFormatFormulas[4].ResetPageNAfter.Text := CrEmptyStr;

•	Any values in the AreaFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.AreaFormatFormulas[4].ResetPageNAfter.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.


ResetPageNAfter property - See also
Related

Hide

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

Suppress

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ResetPageNAfter property - Example
Example

This example retrieves the AreaFormatFormula information, then assigns a ResetPageNAfter formula to the Details area, so that the Page Number will be re-set if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Loop through the Areas}

for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.AreaFormatFormulas[cnt].Section = 'D' then

  begin

    {Clear the ResetPageNAfter formula}

    Crpe1.AreaFormatFormulas[cnt].ResetPageNAfter.Clear;

    {Add the new formula}

    Crpe1.AreaFormatFormulas[cnt].ResetPageNAfter.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


Suppress property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property Suppress: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The Suppress property is a stringlist that contains the Formula used to control the Suppress option of the area formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Suppress (No Drill-Down)" item in the Format | Section dialog of Crystal Reports Designer.

•	The Suppress formula must have a boolean result.

•	To clear an AreaFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the Suppress Formula for the 4th Area}

Crpe1.AreaFormatFormulas[4].Suppress.Text := CrEmptyStr;

•	Any values in the AreaFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.AreaFormatFormulas[4].Suppress.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.


Suppress property - See also
Related

Hide

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Suppress property - Example
Example

This example retrieves the AreaFormatFormula information, then assigns a Suppress formula to the Details area, so that the Details area will be suppressed if the State is California, and the section is blank:

Crpe1.ReportName := 'Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Loop through the Areas}

for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.AreaFormatFormulas[cnt].Section = 'D' then

  begin

{Clear the Suppress formula}

Crpe1.AreaFormatFormulas[cnt].Suppress.Clear;

{Add the new formula}

Crpe1.AreaFormatFormulas[cnt].Suppress.Add('{company.STATE} = "CA"');

Break;

  end;

end;

Crpe1.Execute;


ItemIndex property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current AreaFormatFormulas item number, or set the AreaFormatFormulas object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (AreaFormatFormulas[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the AreaFormatFormulas object is pointing to the first AreaFormatFormulas item:

if Crpe1.AreaFormatFormulas.ItemIndex <> 0 then

  Crpe1.AreaFormatFormulas[0];


Item property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property Item[nIndex: integer]: TCrpeAreaFormatFormulas

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the AreaFormatFormulas object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  AreaFormatFormulas[2] is the same as AreaFormatFormulas.Item[2].

•	Item returns a reference to the AreaFormatFormulas object, so the AreaFormatFormulas properties can be used right after the subscript: AreaFormatFormulas[2].Section := GH;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Set AreaFormatFormulas object to the 2nd item}

Crpe1.AreaFormatFormulas.Item[1];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Set AreaFormatFormulas object to the 2nd item}

Crpe1.AreaFormatFormulas[1];


SectionAsCode property

See also	Example

Applies to

AreaFormatFormulas

Declaration

property SectionAsCode: smallint

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

Section

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The SectionAsCode property can be used to apply formula-based formatting to specific sections based on mathematical calculations or comparisons.  The following code checks each section to see if it is a Group section greater than 1, such as GH2, GH3, etc, and if it is, the Area is suppressed conditionally:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

begin

  if (Crpe1.AreaFormatFormulas[cnt].SectionAsCode mod 1000 > 0) then

Crpe1.AreaFormatFormulas[cnt].Suppress.Text := '{company.STATE} = "CA"';

end;

Crpe1.Execute;

The logic behind the math expression is based on the fact that each group-area increments the Section Code number by 1 (from 0 to 24 are the possible numbers).  So, since 3000 is the general Section Code start number for a Group Header, and is therefore the number to represent GroupHeader 1, 3001 represents GroupHeader 2, 3002 represents GroupHeader 3, etc.  Dividing by 1000 will only give a remainder for those Groups that are greater than 1.


SectionType method

See also	Example

Applies to

AreaFormatFormulas

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1, the SectionType method would return GH.

This method can be used to apply formatting to all the Groups in a Report regardless of their level number.  See the Example for an illustration.


SectionType method - See also
Related

Section

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionType method - Example
Example

The following example uses the SectionType method to apply conditional formatting.  The formatting is to apply to all Group Header areas, so the SectionType method can be used in an expression to apply the changes:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.AreaFormatFormulas.Retrieve;

  for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

  begin

    {if the SectionType is Group Header, apply the change}

    if (Crpe1.AreaFormatFormulas[cnt].SectionType = 'GH') then

Crpe1.AreaFormatFormulas[cnt].Hide.Text := '{company.STATE} = "CA"';

  end;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Retrieve method

See also	Example

Applies to

AreaFormatFormulas

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the AreaFormatFormulas from the Report and stores them in the AreaFormatFormulas object.  If AreaFormatFormulas information was not found, the call returns False.  Be aware that calling Retrieve will first cause the AreaFormatFormulas object to be cleared, so any current information stored in it will be removed.

Note

Since the AreaFormatFormulas object also applies to Subreports, the Retrieve method will obtain the AreaFormatFormulas for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the AreaFormatFormulas information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate AreaFormatFormulas information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.AreaFormatFormulas.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Count method

See also	Example

Applies to

AreaFormatFormulas

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the AreaFormatFormulas object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.AreaFormatFormulas.Retrieve;

  for cnt := 0 to (Crpe1.AreaFormatFormulas.Count - 1) do

Crpe1.AreaFormatFormulas[cnt].KeepTogether.Text := 'True';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Clear method

See also	Example

Applies to

AreaFormatFormulas

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the AreaFormatFormulas object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the AreaFormatFormulas object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the AreaFormatFormulas of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the AreaFormatFormulas properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.AreaFormatFormulas.Clear;

This code clears the AreaFormatFormulas for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.AreaFormatFormulas.Clear;

end;


Add method

See also

Applies to

AreaFormatFormulas

Declaration

function Add(SectionName: TCrAreaFormatFormulasSection): integer;

Type

TCrAreaFormatFormulasSection = string;

Description

The Add method adds an item to the AreaFormatFormulas object and sets the internal index to that item.  It requires a Section name as a parameter, which should be a name corresponding to a Section in the Report.  Sections are named using the Short Section Name convention used in Crystal Reports (see About Section Names for more information).  If the Add method is used, the steps to using AreaFormatFormulas are:

1. Add an item to the AreaFormatFormulas object (you must specify the Section name).

2. Specify values for the desired Formula properties (Hide, KeepTogether, etc.).

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Section names are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the AreaFormatFormulas object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.AreaFormatFormulas.Add('PH');

Crpe1.AreaFormatFormulas.Suppress.Text := 'True';

Crpe1.Output := toWindow;

Crpe1.Execute;


Delete method

See also	Example

Applies to

AreaFormatFormulas

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the AreaFormatFormulas object.  The "nIndex" parameter represents the number of the item in the AreaFormatFormulas object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the AreaFormatFormulas object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.AreaFormatFormulas.Add('PH');

Crpe1.AreaFormatFormulas.Suppress.Text := 'True';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.AreaFormatFormulas.Delete(0);


Send method

See also	Example

Applies to

AreaFormatFormulas

Declaration

function Send: boolean;

Description

The Send method sends the AreaFormatFormulas values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the AreaFormatFormulas settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.AreaFormatFormulas.Send;


Create method

See also

Applies to

AreaFormatFormulas

Declaration

constructor Create;

Description

The Create constructor creates the AreaFormatFormulas object.  It is used internally in the VCL component to create the AreaFormatFormulas object when the component is created, and should not be called outside of the component.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

AreaFormatFormulas

Declaration

destructor Destroy; override;

Description

The Destroy method frees the AreaFormatFormulas object.  It is used internally in the VCL component to destroy the AreaFormatFormulas object when the component is destroyed, and should not be called outside of the component.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method

See also	Example

Applies to

AreaFormatFormulas

Declaration

function IndexOf(SectionName: TCrAreaFormatFormulasSection): integer;

Type

TCrAreaFormatFormulasSection = string;

Description

The IndexOf method takes a Section name and returns the index position of the Section item in the current  AreaFormatFormulas object.

After the Retrieve method has been called, the AreaFormatFormulas object contains one item for each Area in the Report.  This could be illustrated like so (the Section items in your Reports may not be the same):

AreaFormatFormulas	Section items

|------------------------	RH

|------------------------	PH

|------------------------	GH1

|------------------------	GH2

|------------------------	D

|------------------------	GF2

|------------------------	GF1

|------------------------	PF

|------------------------	RF

The IndexOf method can be used to determine if a given Section Name actually exists in the AreaFormatFormulas object before trying to access it.


IndexOf method - See also
Related

Section

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

The following code illustrates the use of the IndexOf method to locate a specific AreaFormatFormula item by it's Area name:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormatFormulas.Retrieve;

{Find Details area}

nItem := Crpe1.AreaFormatFormulas.IndexOf('D');

{If it exists...}

if nItem > -1 then

  {Suppress area if STATE is California}

Crpe1.AreaFormatFormulas[nItem].Suppress.Text := '{company.STATE} = "CA"';

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


CopyFrom method

See also	Example

Applies to

AreaFormatFormulas

Declaration

procedure CopyFrom(Source: TCrpeAreaFormatFormulas);

Description

The CopyFrom method copies the AreaFormatFormulas property values from another TCrpeAreaFormatFormulas object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the AreaFormatFormulas property values to a temporary TCrpeAreaFormatFormulas object:

var

tempAreaFormatFormulas : TCrpeAreaFormatFormulas;

begin

tempAreaFormatFormulas := TCrpeAreaFormatFormulas.Create;

tempAreaFormatFormulas.CopyFrom(Crpe1.AreaFormatFormulas);

{...later, when finished with the temp object...}

tempAreaFormatFormulas.Free;

end;


SectionFormatFormulas

See also	Properties & Methods	Example

Declaration

property SectionFormatFormulas: TCrpeSectionFormatFormulas;

Type

TCrpeSectionFormatFormulas = class(TPersistent)

Description

SectionFormatFormulas encapsulates the formula control over Section Formatting that is available in the Format Section dialog of Crystal Reports designer.  Whereas the Format Section dialog in Crystal Reports contains both Sections and Areas, in the VCL these are separated.  Sections are controlled by SectionFormat and SectionFormatFormulas; Areas are controlled by AreaFormat and AreaFormatFormulas.

The difference between an Area and a Section is that Sections are subdivisions of a given area.  For instance, for any Group in a Report, there can only be one Group Header and one Group Footer.  These are called Areas.  But the Group Header can be subdivided into numerous parts (GH1a, GH1b, etc.).  These subdivisions constitute Sections.  The AreaFormat and AreaFormatFormula properties apply to all the Sections in an Area, whereas the SectionFormat and SectionFormatFormulas apply only to a particular subsection of an Area.

Again, SectionFormatFormulas apply formula control to specific sections (Report Header a, Group Header 2b, Details c, etc.) whereas AreaFormatFormulas apply formula control to the general areas of a Report (Report Header, Group Header 1, Details, etc.).

The Section naming format has been adopted from the Crystal Reports "short" section naming convention, so RH means ReportHeader, GH3 means GroupHeader 3, etc.  See "About Section Names" for more information.

•	The Section property specifies which section of the Report that the formula will apply to.

•	The Retrieve method will obtain the SectionFormatFormula information from the Report.

•	The Count method returns the number of items currently contained in the SectionFormatFormulas object.

•	The Item, and ItemIndex properties can be used to navigate through the different Section items in the SectionFormatFormulas object.

Limitations

SectionFormatFormulas has similar limitations to SectionFormat:

Main Report - For Page Header (PH) and Page Footer (PF) sections, the following Formula names do not apply:

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

Subreports - For Report Header b (RHb) and Report Footer b (RFb) sections, the following Formula names do not apply:

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

Any Formulas that are set for non-applicable Sections will be ignored by the VCL when the Report is run.

Note

Crystal Reports 6.0.x.151 reads the SectionFormatFormula options incorrectly from older 6.0 version Reports (or it may be that the older 6.0 Reports did not quite store the options correctly!).  This is only apparent on the RH and RF Sections of a Subreport.  Instead of the formula limitations (noted in the chart above) appearing in the second Report Header (RHb) and second Report Footer (RFb), they appear on the last sub-section of the Report Header, which could be RHb if there are only 2 sub-sections (which is the default), or it could be anything else (RHd, for example).  Also, the RFb limitations do not appear at all.  This behavior does not appear when designing a new Report in 6.0.x.151, only when loading one designed with an earlier version.


SectionFormatFormulas - See also
Related

AreaFormatFormulas

AreaFormat

SectionFormat

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionFormatFormulas - Properties & Methods
SectionFormatFormulas:

Properties & Methods

SectionFormatFormulas	TCrpe Component

Properties

BackgroundColor

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

Key

Section

SectionAsCode

Navigation

ItemIndex

Item

Methods

Check

Clear

CopyFrom

Count

IndexOf

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


SectionFormatFormulas - Example
Example

This example retrieves the SectionFormatFormula information, then assigns a Suppress formula to the Details "a" section, so that the section will be suppressed if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details 'a' section}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the Suppress formula}

    Crpe1.SectionFormatFormulas[cnt].Suppress.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].Formula.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


Section property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property Section: TCrSectionFormatFormulasSection;

Type

TCrSectionFormatFormulasSection = string;

Description

The Section property specifies the Report Section name that the Formula will apply to.  The property acts as a look-up, to point the SectionFormatFormulas object to the item with the Section specified.  The Retrieve method can be used to fill the SectionFormatFormulas object with information from the Report, thus filling the Section property with appropriate values.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections.  Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.

Note

Whereas objects such as AreaFormat and AreaFormatFormulas work on certain areas, for example, the Details area, SectionFormat and SectionFormatFormulas work on specific individual sub-sections, such as Details "a", Details "b", etc.  The options set in these objects affect only the particular sub-section specified by the Section property.


Section property - See also
Related

About Section Names

IndexOf

Name

Formula

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


Section property - Example
Example

This example retrieves the SectionFormatFormula information, then assigns a Suppress formula to the Details "a" section, so that the section will be suppressed if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details 'a' section}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the Suppress formula}

    Crpe1.SectionFormatFormulas[cnt].Suppress.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].Formula.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


BackgroundColor property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property BackgroundColor: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The BackgroundColor property is a stringlist that contains the Formula used to control the BackgroundColor option of the section formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Background Color" item in the Format | Section dialog of Crystal Reports Designer.

•	The BackgroundColor formula must have a Color result.  This can either be one of the Crystal Reports Color constants, or an RGB value using the Crystal Reports Color(r,g,b) formula function.  The available Crystal Reports Color constants are:

crAqua, crBlack, crBlue, crFuchsia, crGray, crGreen, crLime, crMaroon, crNavy, crOlive, crPurple, crRed, crSilver, crTeal, crWhite, crYellow, crNoColor

The Crystal Reports color constants are used in a Formula from Delphi like this:

Crpe1.SectionFormatFormulas[4].BackgroundColor.Text := 'if {company.STATE} = "CA" then crRed else crWhite';

The Crystal Reports Color(r,g,b) formula function is used in a Formula from Delphi like this:

Crpe1.SectionFormatFormulas[4].BackgroundColor.Text := 'if {company.STATE} = "CA" then Color(122,222,23) else crWhite';

•	To clear a SectionFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the BackgroundColor Formula for the 4th Section}

Crpe1.SectionFormatFormulas[4].BackgroundColor.Text := CrEmptyStr;

•	Any values in the SectionFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.SectionFormatFormulas[4].BackgroundColor.Text := 'if {company.STATE} = "CA" then crRed else crWhite';

See also Using Variables with Formulas.


BackgroundColor property - See also
Related

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


BackgroundColor property - Example
Example

This example retrieves the SectionFormatFormula information, then assigns a BackgroundColor formula to the first Details section, so that the section will be Red in color if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the BackgroundColor formula}

    Crpe1.SectionFormatFormulas[cnt].BackgroundColor.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].BackgroundColor.Add('if {company.STATE} = "CA" then Red else White');

    Break;

  end;

end;

Crpe1.Execute;


KeepTogether property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property KeepTogether: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The KeepTogether property is a stringlist that contains the Formula used to control the KeepTogether option of the section formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Keep Together" item in the Format | Section dialog of Crystal Reports Designer.

•	The KeepTogether formula must have a boolean result.

•	To clear a SectionFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the KeepTogether Formula for the 4th Section}

Crpe1.SectionFormatFormulas[4].KeepTogether.Text := CrEmptyStr;

•	Any values in the SectionFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.SectionFormatFormulas[4].KeepTogether.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.

Limitations

This formula does not apply to Page Header and Page Footer sections.


KeepTogether property - See also
Related

BackgroundColor

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


KeepTogether property - Example
Example

This example retrieves the SectionFormatFormula information, then assigns a KeepTogether formula to the first Details section, so that any records for that section will not be split over two pages if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details 'a' section}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the KeepTogether formula}

    Crpe1.SectionFormatFormulas[cnt].KeepTogether.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].KeepTogether.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


NewPageAfter property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property NewPageAfter: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The NewPageAfter property is a stringlist that contains the Formula used to control the NewPageAfter option of the section formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "New Page After" item in the Format | Section dialog of Crystal Reports Designer.

•	The NewPageAfter formula must have a boolean result, since it is controlling whether the section will be suppressed or not (ie. True or False).

•	To clear a SectionFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the NewPageAfter Formula for the 4th Section}

Crpe1.SectionFormatFormulas[4].NewPageAfter.Text := CrEmptyStr;

•	Any values in the SectionFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.SectionFormatFormulas[4].NewPageAfter.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.

Limitations

This formula does not apply to Page Header and Page Footer sections.


NewPageAfter property - See also
Related

BackgroundColor

KeepTogether

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NewPageAfter property - Example
Example

This example retrieves the SectionFormatFormula information, then assigns a NewPageAfter formula to the first Details section, so that there will be a page break after the section if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details 'a' section}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the NewPageAfter formula}

    Crpe1.SectionFormatFormulas[cnt].NewPageAfter.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].NewPageAfter.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


NewPageBefore property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property NewPageBefore: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The NewPageBefore property is a stringlist that contains the Formula used to control the NewPageBefore option of the section formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "New Page Before" item in the Format | Section dialog of Crystal Reports Designer.

Before setting the Formula property, be sure the SectionFormatFormulas object is pointing to the correct Section, and the Section is pointing to the correct Formula Name item.  See the Section and Item properties for more details.

•	The NewPageBefore formula must have a boolean result.

•	To clear a SectionFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the NewPageBefore Formula for the 4th Section}

Crpe1.SectionFormatFormulas[4].NewPageBefore.Text := CrEmptyStr;

•	Any values in the SectionFormatFormula that must be seen as strings should be put in double quotes, for example:

Crpe1.SectionFormatFormulas[4].NewPageBefore.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.

Limitations

This formula does not apply to Page Header and Page Footer sections.


NewPageBefore property - See also
Related

BackgroundColor

KeepTogether

NewPageAfter

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NewPageBefore property - Example
Example

This example retrieves the SectionFormatFormula information, then assigns a NewPageBefore formula to the first Details section, so that there will be a page break before the section if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details 'a' section}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the NewPageBefore formula}

    Crpe1.SectionFormatFormulas[cnt].NewPageBefore.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].NewPageBefore.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


PrintAtBottomOfPage property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property PrintAtBottomOfPage: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The PrintAtBottomOfPage property is a stringlist that contains the Formula used to control the PrintAtBottomOfPage option of the section formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Print at Bottom of Page" item in the Format | Section dialog of Crystal Reports Designer.

•	The PrintAtBottomOfPage formula must have a boolean result.

•	To clear a SectionFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the PrintAtBottomOfPage Formula for the 4th Section}

Crpe1.SectionFormatFormulas[4].PrintAtBottomOfPage.Text := CrEmptyStr;

•	Any values in the SectionFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.SectionFormatFormulas[4].PrintAtBottomOfPage.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.

Limitations

This formula does not apply to Page Header or Page Footer areas.


PrintAtBottomOfPage property - See also
Related

BackgroundColor

KeepTogether

NewPageAfter

NewPageBefore

ResetPageNAfter

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintAtBottomOfPage property - Example
Example

This example retrieves the SectionFormatFormula information, then assigns a PrintAtBottomOfPage formula to the first Details section, so that the section will be printed at the bottom of the page if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details area}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the PrintAtBottomOfPage formula}

    Crpe1.SectionFormatFormulas[cnt].PrintAtBottomOfPage.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].PrintAtBottomOfPage.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


ResetPageNAfter property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property ResetPageNAfter: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The ResetPageNAfter property is a stringlist that contains the Formula used to control the ResetPageNAfter option of the section formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Reset Page Number After" item in the Format | Section dialog of Crystal Reports Designer.

•	The ResetPageNAfter formula must have a boolean result.

•	To clear a SectionFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the ResetPageNAfter Formula for the 4th Section}

Crpe1.SectionFormatFormulas[4].ResetPageNAfter.Text := CrEmptyStr;

•	Any values in the SectionFormatFormula that must be seen as strings should be put in double quotes, for example:

Crpe1.SectionFormatFormulas[4].ResetPageNAfter.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.


ResetPageNAfter property - See also
Related

BackgroundColor

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

Suppress

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ResetPageNAfter property - Example
Example

This example retrieves the SectionFormatFormula information, then assigns a ResetPageNAfter formula to the first Details section, so that the Page Number will be re-set if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details 'a' section}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the ResetPageNAfter formula}

    Crpe1.SectionFormatFormulas[cnt].ResetPageNAfter.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].ResetPageNAfter.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


Suppress property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property Suppress: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The Suppress property is a stringlist that contains the Formula used to control the Suppress option of the section formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Suppress (No Drill-Down)" item in the Format | Section dialog of Crystal Reports Designer.

•	The Suppress formula must have a boolean result, since it is controlling whether the section will be suppressed or not (ie. True or False).

•	To clear a SectionFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the Suppress Formula for the 4th Section}

Crpe1.SectionFormatFormulas[4].Suppress.Text := CrEmptyStr;

•	Any values in the SectionFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.SectionFormatFormulas[4].Suppress.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.


Suppress property - See also
Related

BackgroundColor

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

SuppressBlankSection

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Suppress property - Example
Example

This example retrieves the SectionFormatFormula information, then assigns a Suppress formula to the first Details section, so that the section will be suppressed if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details 'a' section}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the Suppress formula}

    Crpe1.SectionFormatFormulas[cnt].Suppress.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].Suppress.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


SuppressBlankSection property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property SuppressBlankSection: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The SuppressBlankSection property is a stringlist that contains the Formula used to control the SuppressBlankSection option of the section formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Suppress Blank Section" item in the Format | Section dialog of Crystal Reports Designer.

•	The SuppressBlankSection formula must have a boolean result, since it is controlling whether the blank section will be suppressed or not (ie. True or False).

•	To clear a SectionFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the SuppressBlankSection Formula for the 4th Section}

Crpe1.SectionFormatFormulas[4].SuppressBlankSection.Text := CrEmptyStr;

•	Any values in the SectionFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.SectionFormatFormulas[4].SuppressBlankSection.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.


SuppressBlankSection property - See also
Related

BackgroundColor

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

UnderlaySection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SuppressBlankSection property - Example
Example

This example retrieves the SectionFormatFormula information, then assigns a SuppressBlankSection formula to the first Details section, so that the section will be suppressed if the State is California and the section is blank:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details 'a' section}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the SuppressBlankSection formula}

    Crpe1.SectionFormatFormulas[cnt].SuppressBlankSection.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].SuppressBlankSection.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


UnderlaySection property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property UnderlaySection: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The UnderlaySection property is a stringlist that contains the Formula used to control the UnderlaySection option of the section formatting of a Report. It represents and acts on the same formula that appears when the formula button is pressed beside the "Underlay Following Sections" item in the Format | Section dialog of Crystal Reports Designer.

•	The UnderlaySection formula must have a boolean result.

•	To clear a SectionFormatFormula in a Report, so that it is blank, use the CrEmptyStr constant.

{Clear the UnderlaySection Formula for the 4th Section}

Crpe1.SectionFormatFormulas[4].UnderlaySection.Text := CrEmptyStr;

•	Any values in the SectionFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.SectionFormatFormulas[4].UnderlaySection.Text := '{company.STATE} = "CA"';

See also Using Variables with Formulas.


UnderlaySection property - See also
Related

BackgroundColor

KeepTogether

NewPageAfter

NewPageBefore

PrintAtBottomOfPage

ResetPageNAfter

Suppress

SuppressBlankSection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


UnderlaySection property - Example
Example

This example retrieves the SectionFormatFormula information, then assigns an UnderlaySection formula to the first Details section, so that it will underlay the following section if the State is California:

Crpe1.ReportName := 'Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Loop through the Sections}

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  {Check for Details 'a' section}

  if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then

  begin

    {Clear the UnderlaySection formula}

    Crpe1.SectionFormatFormulas[cnt].UnderlaySection.Clear;

    {Add the new formula}

    Crpe1.SectionFormatFormulas[cnt].UnderlaySection.Add('{company.STATE} = "CA"');

    Break;

  end;

end;

Crpe1.Execute;


ItemIndex property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current SectionFormatFormulas item number, or set the SectionFormatFormulas object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (SectionFormatFormulas[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the SectionFormatFormulas object is pointing to the first SectionFormatFormulas item:

if Crpe1.SectionFormatFormulas.ItemIndex <> 0 then

  Crpe1.SectionFormatFormulas[0];


Item property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property Item[nIndex: integer]: TCrpeSectionFormatFormulas;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the SectionFormatFormulas object, allowing the object to be treated like an array.

•	Item is a default property, it does not need to be specified when using the subscript:  SectionFormatFormulas[2] is the same as SectionFormatFormulas.Item[2].

•	Item returns a reference to the SectionFormatFormulas object, so the SectionFormatFormulas properties can be used right after the subscript: SectionFormatFormulas[2].Section := GH1a;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Set SectionFormatFormulas object to the 2nd item}

Crpe1.SectionFormatFormulas.Item[1];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Set SectionFormatFormulas object to the 2nd item}

Crpe1.SectionFormatFormulas[1];


SectionAsCode property

See also	Example

Applies to

SectionFormatFormulas

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

Section

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The SectionAsCode property can be used to apply formula-based formatting to specific sections based on mathematical calculations or comparisons.  The following code checks each section to see if it is a "b" section, such as RHb, PHb, Db, etc, and if it is, the background color is changed to red according to a formula:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

begin

  if (Crpe1.SectionFormatFormulas[cnt].SectionAsCode mod 1000 = 25) then

Crpe1.SectionFormatFormulas[cnt].BackgroundColor.Text := '{company.STATE} = "CA"';

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

The logic behind the math expression is based on the fact that each sub-section increments the Section Code number by 25 (from 0 to 975 are the possible numbers).  So, since 3000 is the general Section Code start number for a Group Header, and is therefore the number to represent GroupHeader 1a, 3025 represents GroupHeader 1b, 3050 represents GroupHeader 1c, etc.  Therefore, in order to find the "b" sections we must divide by 1000, and if the remainder is 25, it is a "b" section.  This formula also works for Sections that do not have Group options, such as Details (Da = 4000, Db = 4025, etc.).


SectionType method

See also	Example

Applies to

SectionFormatFormulas

Declaration

property SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1a, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier.  See the Example for an illustration.


SectionType method - See also
Related

Section

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionType method - Example
Example

The following example uses the SectionType method to apply conditional formatting.  The formatting is to apply to all Group Header sections, so the SectionType method can be used in an expression to apply the changes:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SectionFormatFormulas.Retrieve;

  for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

  begin

    {if the SectionType is Group Header, apply the change}

    if (Crpe1.SectionFormatFormulas[cnt].SectionType = 'GH') then

Crpe1.SectionFormatFormulas[cnt].Suppress.Text := '{company.STATE} = "CA"';

  end;

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Retrieve method

See also	Example

Applies to

SectionFormatFormulas

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SectionFormatFormulas from the Report and stores them in the SectionFormatFormulas object.  If SectionFormatFormulas information was not found, the call returns False.  Be aware that calling Retrieve will first cause the SectionFormatFormulas object to be cleared, so any current information stored in it will be removed.

Note

Since the SectionFormatFormulas object also applies to Subreports, the Retrieve method will obtain the SectionFormatFormulas for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the SectionFormatFormulas information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate SectionFormatFormulas information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.SectionFormatFormulas.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Count method

See also	Example

Applies to

SectionFormatFormulas

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the SectionFormatFormulas object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SectionFormatFormulas.Retrieve;

  for cnt := 0 to (Crpe1.SectionFormatFormulas.Count - 1) do

Crpe1.SectionFormatFormulas[cnt].KeepTogether.Text := 'True';

  Crpe1.Output := toWindow;

  Crpe1.Execute;

end;


Check method

See also	Example

Applies to

SectionFormatFormulas

Declaration

function Check: boolean;

Description

The Check method can be used to check the syntax of an SectionFormat Formula before running the Report.  Check returns a boolean value:

True	: SectionFormat Formula is good.

False	: SectionFormat Formula has an error.

Note

Check is not working properly at this time (it always returns True).


Check method - See also
Related

Formula

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Check method - Example
Example

The Check method does not work properly for SectionFormatFormulas at this time.


Clear method

See also	Example

Applies to

SectionFormatFormulas

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the SectionFormatFormulas object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the SectionFormatFormulas object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the SectionFormatFormulas of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the SectionFormatFormulas properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.SectionFormatFormulas.Clear;

This code clears the SectionFormatFormulas for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.SectionFormatFormulas.Clear;

end;


Add method

See also	Example

Applies to

SectionFormatFormulas

Declaration

function Add(SectionName: TCrSectionFormatFormulasSection): integer;

Type

TCrSectionFormatFormulasSection = string;

Description

The Add method adds an item to the SectionFormatFormulas object and sets the internal index to that item.  It requires a Section name as a parameter, which should be a name corresponding to a Section in the Report.

Sections are named using the Short Section Name convention used in Crystal Reports (see About Section Names for more information).  If the Add method is used, the steps to using SectionFormatFormulas are:

1. Add an item to the SectionFormatFormulas object (you must specify the Section name).

2. Specify values for the properties (Name, Formula, etc.).

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Section names are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the SectionFormatFormulas object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.SectionFormatFormulas.Add('PH');

Crpe1.SectionFormatFormulas.Suppress.Text := 'True';

Crpe1.Output := toWindow;

Crpe1.Execute;


Delete method

See also	Example

Applies to

SectionFormatFormulas

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the SectionFormatFormulas object.  The "nIndex" parameter represents the number of the item in the SectionFormatFormulas object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the SectionFormatFormulas object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report}

Crpe1.SectionFormatFormulas.Add('PH');

Crpe1.SectionFormatFormulas.Suppress.Text := 'True';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SectionFormatFormulas.Delete(0);


Send method

See also	Example

Applies to

SectionFormatFormulas

Declaration

function Send: boolean;

Description

The Send method sends the SectionFormatFormulas values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the SectionFormatFormulas settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SectionFormatFormulas.Send;


Create method

See also

Applies to

SectionFormatFormulas

Declaration

constructor Create;

Description

The Create constructor creates the SectionFormatFormulas object.  It is used internally in the VCL component to create the SectionFormatFormulas object when the component is created, and should not be called outside of the component.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

SectionFormatFormulas

Declaration

destructor Destroy; override;

Description

The Destroy method frees the SectionFormatFormulas object.  It is used internally in the VCL component to destroy the SectionFormatFormulas object when the component is destroyed, and should not be called outside of the component.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method

See also	Example

Applies to

SectionFormatFormulas

Declaration

function IndexOf(SectionName: TCrSectionFormatFormulasSection): integer;

Type

TCrSectionFormatFormulasSection = string;

Description

The IndexOf method takes a Section name and returns the index position of the Section item in the current  SectionFormatFormulas object.

After the Retrieve method has been called, the SectionFormatFormulas object contains one item for each Section in the Report.  This could be illustrated like so (the Section items in your Reports may not be the same):

SectionFormatFormulas	Section items

|------------------------	RHa

|------------------------	RHb

|------------------------	PH

|------------------------	GH1

|------------------------	GH2a

|------------------------	GH2b

|------------------------	D

|------------------------	GF2b

|------------------------	GF2a

|------------------------	GF1

|------------------------	PF

|------------------------	RFa

|------------------------	RFb

The IndexOf method can be used to determine if a given Section Name actually exists in the SectionFormatFormulas object before trying to access it.


IndexOf method - See also
Related

Section

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

The following code illustrates the use of the IndexOf method to locate a specific Section:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SectionFormatFormulas.Retrieve;

{Find Details "a" section}

nItem := Crpe1.SectionFormatFormulas.IndexOf('Da');

{If it exists...}

if nItem > -1 then

  {Suppress section if STATE is California}

Crpe1.SectionFormatFormulas[nItem].Suppress.Text := '{company.STATE} = "CA"';

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


CopyFrom method

See also	Example

Applies to

SectionFormatFormulas

Declaration

procedure CopyFrom(Source: TCrpeSectionFormatFormulas);

Description

The CopyFrom method copies the SectionFormatFormulas property values from another TCrpeSectionFormatFormulas object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the SectionFormatFormulas property values to a temporary TCrpeSectionFormatFormulas object:

var

tempSectionFormatFormulas : TCrpeSectionFormatFormulas ;

begin

tempSectionFormatFormulas  := TCrpeSectionFormatFormulas.Create;

tempSectionFormatFormulas .CopyFrom(Crpe1.SectionFormatFormulas);

{...later, when finished with the temp object...}

tempSectionFormatFormulas .Free;

end;


WindowCursor

See also	Properties & Methods	Example

Declaration

property WindowCursor : TCrpeWindowCursor;

Type

TCrpeWindowCursor = class(TPersistent)

Description

The WindowCursor properties can be used to change the shape of the Mouse Cursor when it passes over certain areas of the Preview Window.  The specific areas that can be affected are:

GroupArea	- Any Group section

GroupAreaField	- Any Field in a Group section

DetailArea	- Any Detail section

DetailAreaField	- Any Field in a Detail section

Graph	- Any Graph

The Mouse Cursor shapes available are:

wcDefault	- No change in cursor shape.  The cursor shape will be either according to Crystal Reports standard behaviour, if the Report has not been run yet, or whatever the last chosen cursor shape was if the Report was run just previously.

wcArrow

wcCross

wcIBeam

wcUpArrow

wcSizeAll

wcSizeNWSE

wcSizeNESW

wcSizeWE

wcSizeNS

wcNo

wcWait

wcAppStart

wcHelp

wcMagnify

WindowCursor would normally be used in conjunction with WindowEvents, to trigger some action in response to a user-event on the Preview Window.  The change in Cursor shape would be an indication to the user that a special action is to occur when that area of the Window is clicked.


WindowCursor - See also
Related

WindowEvents

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


WindowCursor - Properties & Methods
WindowCursor:

Properties & Methods

WindowCursor	TCrpe Component

Properties

DetailArea

DetailAreaField

GroupArea

GroupAreaField

Graph

Methods

Clear

CopyFrom

Retrieve

Send

Constructor

Create


WindowCursor - Example
Example

The example below sets the Mouse Cursor to a Magnifying Glass when it passes over a Group Area on the Preview Window:

Crpe1.ReportName := 'C:\Company.rpt;

Crpe1.WindowCursor.GroupArea := wcMagnify;

Crpe1.Output := toWindow;

Crpe1.Execute;


GroupArea property

See also	Example

Applies to

WindowCursor

Declaration

property GroupArea: TCrWindowCursor;

Types

TCrWindowCursor = (wcDefault, wcArrow, wcCross, wcIBeam, wcUpArrow, wcSizeAll, wcSizeNWSE, wcSizeNESW, wcSizeWE, wcSizeNS, wcNo, wcWait, wcAppStart, wcHelp, wcMagnify);

Description

The GroupArea property controls what Mouse Cursor shape will appear when the Mouse is passing over a Group section on the runtime Preview Window.


GroupArea property - See also
Related

DetailArea

DetailAreaField

GroupAreaField

Graph

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupArea property - Example
Example

The example below sets the Mouse Cursor to a Magnifying Glass when it passes over a Group Area on the Preview Window:

Crpe1.ReportName := 'C:\Company.rpt;

Crpe1.WindowCursor.GroupArea := wcMagnify;

Crpe1.Output := toWindow;

Crpe1.Execute;


GroupAreaField property

See also	Example

Applies to

WindowCursor

Declaration

property GroupAreaField: TCrWindowCursor;

Types

TCrWindowCursor = (wcDefault, wcArrow, wcCross, wcIBeam, wcUpArrow, wcSizeAll, wcSizeNWSE, wcSizeNESW, wcSizeWE, wcSizeNS, wcNo, wcWait, wcAppStart, wcHelp, wcMagnify);

Description

The GroupAreaFied property controls what Mouse Cursor shape will appear when the Mouse is passing over a Field in a Group section on the runtime Preview Window.


GroupAreaField property - See also
Related

DetailArea

DetailAreaField

GroupArea

Graph

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupAreaField property - Example
Example

The example below sets the Mouse Cursor to a Magnifying Glass when it passes over a Group Area Field on the Preview Window:

Crpe1.ReportName := 'C:\Company.rpt;

Crpe1.WindowCursor.GroupAreaField := wcMagnify;

Crpe1.Output := toWindow;

Crpe1.Execute;


DetailArea property

See also	Example

Applies to

WindowCursor

Declaration

property DetailArea: TCrWindowCursor;

Types

TCrWindowCursor = (wcDefault, wcArrow, wcCross, wcIBeam, wcUpArrow, wcSizeAll, wcSizeNWSE, wcSizeNESW, wcSizeWE, wcSizeNS, wcNo, wcWait, wcAppStart, wcHelp, wcMagnify);

Description

The DetailArea property controls what Mouse Cursor shape will appear when the Mouse is passing over a Detail section on the runtime Preview Window.


DetailArea property - See also
Related

DetailAreaField

GroupArea

GroupAreaField

Graph

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DetailArea property - Example
Example

The example below sets the Mouse Cursor to a Magnifying Glass when it passes over a Detail Area on the Preview Window:

Crpe1.ReportName := 'C:\Company.rpt;

Crpe1.WindowCursor.DetailArea := wcMagnify;

Crpe1.Output := toWindow;

Crpe1.Execute;


DetailAreaField property

See also	Example

Applies to

WindowCursor

Declaration

property DetailAreaField: TCrWindowCursor;

Types

TCrWindowCursor = (wcDefault, wcArrow, wcCross, wcIBeam, wcUpArrow, wcSizeAll, wcSizeNWSE, wcSizeNESW, wcSizeWE, wcSizeNS, wcNo, wcWait, wcAppStart, wcHelp, wcMagnify);

Description

The DetailAreaField property controls what Mouse Cursor shape will appear when the Mouse is passing over a Field in a Detail section on the runtime Preview Window.


DetailAreaField property - See also
Related

DetailArea

GroupArea

GroupAreaField

Graph

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DetailAreaField property - Example
Example

The example below sets the Mouse Cursor to a Magnifying Glass when it passes over a Detail Area Field on the Preview Window:

Crpe1.ReportName := 'C:\Company.rpt;

Crpe1.WindowCursor.DetailAreaField := wcMagnify;

Crpe1.Output := toWindow;

Crpe1.Execute;


Graph property

See also	Example

Applies to

WindowCursor

Declaration

property Graph: TCrWindowCursor;

Types

TCrWindowCursor = (wcDefault, wcArrow, wcCross, wcIBeam, wcUpArrow, wcSizeAll, wcSizeNWSE, wcSizeNESW, wcSizeWE, wcSizeNS, wcNo, wcWait, wcAppStart, wcHelp, wcMagnify);

Description

The Graph property controls what Mouse Cursor shape will appear when the Mouse is passing over a Graph on the runtime Preview Window.


Graph property - See also
Related

DetailArea

DetailAreaField

GroupArea

GroupAreaField

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Graph property - Example
Example

The example below sets the Mouse Cursor to a Magnifying Glass when it passes over a Graph Area on the Preview Window:

Crpe1.ReportName := 'C:\Company.rpt;

Crpe1.WindowCursor.GraphArea := wcMagnify;

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

WindowCursor

Declaration

procedure Clear;

Description

This method can be used to set all of the WindowCursor properties back to default:

GroupArea       := wcDefault;

GroupAreaField  := wcDefault;

DetailArea      := wcDefault;

DetailAreaField := wcDefault;

Graph           := wcDefault;


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the WindowCursor properties:

Crpe1.WindowCursor.Clear;


Retrieve method

See also	Example

Applies to

WindowCursor

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the WindowCursor information from the Report and stores it in the WindowCursor object.  If WindowCursor information was not found, the call returns False.


Retrieve method - See also
Related

Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

This code sample retrieves the WindowCursor settings from a Report.  Unless the Report has already been run with specific WindowCursor settings (or if it has Saved Data), the retrieved values will be default:

Crpe1.ReportName := 'Company.rpt';

Crpe1.WindowCursor.Retrieve;


Send method

See also	Example

Applies to

WindowCursor

Declaration

function Send: boolean;

Description

The Send method sends the WindowCursor values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the WindowCursor settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.WindowCursor.Send;


Create method

See also

Applies to

WindowCursor

Declaration

constructor Create;

Description

The Create constructor creates the WindowCursor object.  It is used internally in the VCL component to create the WindowCursor object and should not be called outside of the component.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method

See also	Example

Applies to

WindowCursor

Declaration

procedure CopyFrom(Source: TCrpeWindowCursor);

Description

The CopyFrom method copies the WindowCursor property values from another TCrpeWindowCursor object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the WindowCursor property values to a temporary TCrpeWindowCursor object:

var

tempWindowCursor : TCrpeWindowCursor;

begin

tempWindowCursor := TCrpeWindowCursor.Create;

tempWindowCursor.CopyFrom(Crpe1.WindowCursor);

{...later, when finished with the temp object...}

tempWindowCursor.Free;

end;


GroupOptions

See also	Properties & Methods	Example

Declaration

property GroupOptions : TCrpeGroupOptions;

Type

TCrpeGroupOptions = class(TPersistent)

Description

GroupOptions contains all the properties that relate to Grouping, including TopN control.

•	The Number property specifies the Group Number.  Groups are numbered from 1 up, so the first Group in a Report is 1.

•	The Condition property setting determines when a new group will be formed.  For Groups based on Date and Boolean fields, there are specific values that can be assigned.  For all other Groups, "AnyChange" is the only condition that is applicable.

•	The Direction property determines in what order the Groups will be sorted: gdAscending, gdDescending, gdOriginal, gdSpecified, or gdDefault.

•	The Field property contains the actual Grouping field, which can be a Database field or a Formula field.

•	The GroupType property specifies the data type of the field or formula that the Group is based  on: gtOther, gtDate, or gtBoolean.

•	The KeepTogether property specifies whether the Group will be split over two pages or not when it will not all fit at the bottom of a page.

•	The RepeatGH property specifies whether the Group Header will be repeated on the top of the next page when a Group is split over two pages.

•	The Retrieve method will fetch the GroupOptions values from the Report and fill the GroupOptions object with corresponding items.

•	The Count method returns the number of GroupOptions items currently contained in the GroupOptions object.

•	The Item and ItemIndex properties can be used to navigate through the GroupOptions object.

•	The Clear method removes all items from the GroupOptions object.

•	The Add and Delete methods provide a manual alternative to Retrieve/Clear for adding and deleting items from  the GroupOptions object.

There are four properties that apply specifically to TopN Group selection.  TopN refers to the selecting and ordering of Groups.  The sorting part is also available via the GroupSortFields object, but the selecting part is not.  This can be used to show only a specified number of Groups, ie. the Top 5 based on a certain summary field.

•	The TopNGroups property specifies the number of Groups to select.

•	The TopNSortField property specifies the summary field that the Groups will be ordered by.

•	The TopNDiscardOthers property specifies whether the Groups that are out of the N range will be discarded or whether they will be included in a Group called "Others".

•	The TopNOptions property specifies how the TopN properties will be applied.  The options are: tnUnsorted, tnSorted, tnTopN, tnBottomN, and tnDefault.

Note

GroupOptions is new as of Crystal Reports 6.0, and is therefore not available to Crystal 5.0 users (they will have to use GroupCondition instead).  GroupCondition can still be used with Crystal 6.0 if desired, but it is not as powerful as GroupOptions (it lacks the TopN control, etc.).  Also, GroupCondition and GroupOptions should not be used together, since they both cover the same ground.


GroupOptions - See also
Related

GroupCondition

GroupSortFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupOptions - Properties & Methods
GroupOptions:

Properties & Methods

GroupOptions	TCrpe Component

Properties

Condition

Direction

Field

GroupType

KeepTogether

RepeatGH

TopNDiscardOthers

TopNGroups

TopNOptions

TopNSortField

Key

Number

Navigation

Item

ItemIndex

Methods

Retrieve

CopyFrom

Count

Clear

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


GroupOptions - Example
Example

This sample retrieves the GroupOptions values from the Report, and sets the first Group to the {company.STATE} field, ascending:

Crpe1.ReportName := 'C:\Company.rpt';

with Crpe1.GroupOptions do

begin

Retrieve;

Number := 1;

Field := '{company.STATE}';

Condition := AnyChange;

Direction := gcAscending;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


Number property

See also	Example

Applies to

GroupOptions

Declaration

property Number: TCrGroupOptionsNumber;

Types

TCrGroupOptionsNumber = integer;

Description

The Number property specifies the Group Number.  Unlike most of the other properties, Number is one-based, therefore the first Group is number one (1).  This was done to be consistent with the Section naming convention wherein the first Group Header is GH1, etc.  The GroupOptions object, however, is still zero-based, thus the first item in GroupOptions is still GroupOptions[0].

•	Number is a key property, and therefore serves as a lookup; that is, assigning it a value will cause the GroupOptions object to point to the item that has a Group Number with the same value.

•	Before using the Number property to navigate through the GroupOptions, the Retrieve method should be called, or the manual Add method.


Number property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

This example retrieves the GroupOptions values from the Report, and uses the Number property to set the first Group to the {company.STATE} field:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the GroupOptions from the Report}

Crpe1.GroupOptions.Retrieve;

{Set the GroupOptions object to Group Number 1}

Crpe1.GroupOptions.Number := 1;

{Assign the values for Group Number 1}

Crpe1.GroupOptions.Field := '{company.STATE}';

Crpe1.GroupOptions.Condition := AnyChange;

Crpe1.GroupOptions.Direction := gcAscending;

Crpe1.Output := toWindow;

Crpe1.Execute;


Field property

See also	Example

Applies to

GroupOptions

Declaration

property Field: string;

Description

The Field property specifies the database field or formula field that will control grouping.

•	Enclose field names in braces: {company.STATE}.

•	If a formula field is the grouping field, use the @ sign before the formula name: {@FormulaName}.

•	The value cannot be greater than 512 characters long, or it will be truncated.


Field property - See also
Related

Condition

Direction

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Field property - Example
Example

This example retrieves the GroupOptions values from the Report, and uses the Field property to set the first Group to the {company.STATE} field:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the GroupOptions from the Report}

Crpe1.GroupOptions.Retrieve;

{Assign the values for Group Number 1}

Crpe1.GroupOptions[0].Field := '{company.STATE}';

Crpe1.GroupOptions[0].Condition := AnyChange;

Crpe1.GroupOptions[0].Direction := gcAscending;

Crpe1.Output := toWindow;

Crpe1.Execute;


Condition property

See also	Example

Applies to

GroupOptions

Declaration

property Condition : TCrGroupCondition

Types

TCrGroupCondition = (AnyChange, dateDaily, dateWeekly, dateBiWeekly, dateSemiMonthly, dateMonthly, dateQuarterly, dateSemiAnnually, dateAnnually, boolToYes, boolToNo, boolEveryYes, boolEveryNo, boolNextIsYes, boolNextIsNo, timeBySecond, timeByMinute, timeByHour, timeByAMPM);

Description

The Condition property determines when a new Group is begun.  Groups based on Date, Boolean, Time, or DateTime fields are the only ones that have specific Condition values.  All other types of fields use AnyChange as the Group Condition value.

For Groups based on Date fields, the options are:

dateDaily	- Triggers a grouping for every Day.

dateWeekly	- Triggers a grouping for every Week.

dateBiWeekly	- Triggers a grouping for every second Week.

dateSemiMonthly	- Triggers a grouping for every half Month.

dateMonthly	- Triggers a grouping for every Month.

dateQuarterly	- Triggers a grouping for every quarter Year.

dateSemiAnnually	- Triggers a grouping for every half Year.

dateAnnually	- Triggers a grouping for every Year.

For Groups based on Boolean fields, the options are:

boolToYes	- Triggers a grouping every time the Group field value changes from No to Yes.

boolToNo	- Triggers a grouping every time the Group field value changes from Yes to No.

boolEveryYes	- Triggers a grouping every time the Group field value is Yes.

boolEveryNo	- Triggers a grouping every time the Group field value is No.

boolNextIsYes	- Triggers a grouping every time the next value in the Group field is Yes.

boolNextIsNo	- Triggers a grouping every time the next value in the Group field is No.

For Groups based on Time or DateTime fields, the options are:

timeBySecond	- Triggers a grouping every time the Group field value changes seconds.

timeByMinute	- Triggers a grouping every time the Group field value changes minutes.

timeByHour	- Triggers a grouping every time the Group field value changes hours.

timeByAMPM	- Triggers a grouping every time the Group field value changes from AM to PM.


Condition property - See also
Related

Direction

Field

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Condition property - Example
Example

The code below sets the first Group of a Report to a date field, with the Condition for the Group set to "daily":

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupCondition.Retrieve;

Crpe1.GroupCondition[0].Field := '{invoice.DATE}';

Crpe1.GroupCondition[0].Condition := dateDaily;

Crpe1.GroupCondition[0].Direction := gcDescending;

Crpe1.Output := toWindow;

Crpe1.Execute;


Direction property

See also	Example

Applies to

GroupOptions

Declaration

property Direction: TCrGroupDirection

Types

TCrGroupDirection = (gdDescending, gdAscending, gdOriginal, gdSpecified, gdDefault);

Description

The Direction property determines how the Groups will be sorted.  This does not affect the sorting of records within the Group, just the sorting of the actual Groups themselves.  For example, if your grouping field is {company.STATE} then the Direction would determine if the first group was AK (gcAscending) or WY (gcDescending).

The five Direction options are:

gcDescending	- Sorts data in descending order (Z to A, 9 to 1).

gcAscending	- Sorts data in ascending order (A to Z, 1 to 9).

gcOriginal	- Sorts data in its original order.

gcSpecified	- Sorts data in a specified order.

gcDefault	- No change from current Report settings.

Note

In order to use gcSpecified, there must be a specified order saved with the Report.  Specified order requires the creation of custom Groups, which cannot be done at runtime, so if these Groups do not exist, setting the Condition to gcSpecified will result in error 511, "Invalid Sort Direction".


Direction property - See also
Related

Condition

Field

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Direction property - Example
Example

The code below sets the first Group of a Report to a date field, with the Direction to "descending":

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupCondition.Retrieve;

Crpe1.GroupCondition[0].Field := '{invoice.DATE}';

Crpe1.GroupCondition[0].Condition := dateDaily;

Crpe1.GroupCondition[0].Direction := gcDescending;

Crpe1.Output := toWindow;

Crpe1.Execute;


GroupType property

See also	Example

Applies to

GroupOptions

Declaration

property GroupType: TCrGroupType

Type

TCrGroupType = (gtOther, gtDate, gtBoolean, gtTime);

Description

The GroupType property specifies the data type of the grouping field.

gtOther	- the field is any other data type other than Date or Boolean.

gtDate	- the field is of Date type.

gtBoolean	- the field is of Boolean type.

gtTime	- the field is of Time type.

Note

It is important that the GroupType match the Condition, ie. if GroupType is gtBoolean, then the Condition must be set to one of the Boolean conditions, or an error will occur.


GroupType property - See also
Related

Condition

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupType property - Example
Example

The code below loops through all the GroupOptions items, and when it locates an item with GroupType of Date, then it changes the Condition that triggers the Group to "daily":

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupOptions.Retrieve;

for cnt := 0 to (Crpe1.GroupOptions.Count - 1) do

begin

  if Crpe1.GroupOptions[cnt].GroupType = gtDate then

    Crpe1.GroupOptions[cnt].Condition := dateDaily;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


RepeatGH property

See also	Example

Applies to

GroupOptions

Declaration

property RepeatGH: TCrBoolean

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

RepeatGH determines whether the Group Header will repeat on each new page of the Report when the grouped records are split over more than one page.


RepeatGH property - See also
Related

KeepTogether

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


RepeatGH property - Example
Example

This example shows how to set the RepeatGH and KeepTogether properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupOptions.Retrieve;

for cnt := 0 to (Crpe1.GroupOptions.Count - 1) do

begin

Crpe1.GroupOptions[cnt].RepeatGH := cTrue;

Crpe1.GroupOptions[cnt].KeepTogether := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


KeepTogether property

See also	Example

Applies to

GroupOptions

Declaration

property KeepTogether: TCrBoolean

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The KeepTogether property encapsulates the functionality of the "Keep Group Together" option which is available when a Group is created or modified in the Seagate Crystal Reports designer.  When set to cTrue, it prevents a Group from splitting on Page Break (if possible).


KeepTogether property - See also
Related

RepeatGH

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


KeepTogether property - Example
Example

This example shows how to set the RepeatGH and KeepTogether properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupOptions.Retrieve;

for cnt := 0 to (Crpe1.GroupOptions.Count - 1) do

begin

Crpe1.GroupOptions[cnt].RepeatGH := cTrue;

Crpe1.GroupOptions[cnt].KeepTogether := cTrue;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


TopNOptions property

See also	Example

Applies to

GroupOptions

Declaration

property TopNOptions: TCrTopNOptions

Type

TCrTopNOptions = (tnUnsorted, tnSorted, tnTopN, tnBottomN, tnDefault);

Description

The TopNOptions property determines if the TopN feature is active or not.  If TopNOptions is set to tnUnsorted or tnDefault, the TopN features are deactivated.  The possible values for this property are:

tnUnsorted	- Groups are not sorted by a summary field.

tnSorted	- Groups are sorted by the TopNField (a summary field).

tnTopN	- Number of Groups are selected based on the value of the TopNGroups property from highest down.

tnBottomN	- Number of Groups are selected based on the value of the TopNGroups property from lowest up.

tnDefault	- TopN Options are left as defined in the Report.


TopNOptions property - See also
Related

TopNDiscardOthers

TopNGroups

TopNSortField

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TopNOptions property - Example
Example

This example shows how to use the TopN features of GroupOptions.  In this case, the top 10 groups (based on the summary of their Sales) will be shown on the Report.  All other groups will be discarded.  The TopN selection will take place on the outer Group (Group number 1):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupOptions.Retrieve;

Crpe1.GroupOptions[0].TopNOptions := tnTopN;

Crpe1.GroupOptions[0].TopNGroups := 10;

Crpe1.GroupOptions[0].TopNSortField :=

'Sum({company.SALES},{company.STATE})';

Crpe1.GroupOptions[0].TopNDiscardOthers := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


TopNGroups property

See also	Example

Applies to

GroupOptions

Declaration

property TopNGroups: smallint

Description

TopNGroups specifies how many groups will be included in the TopN/BottomN selection.  The TopNOptions property must be set to either tnTopN or tnBottomN for this property to have any effect.


TopNGroups property - See also
Related

TopNDiscardOthers

TopNOptions

TopNSortField

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TopNGroups property - Example
Example

This example shows how to use the TopN features of GroupOptions.  In this case, the top 10 groups (based on the summary of their Sales) will be shown on the Report.  All other groups will be discarded.  The TopN selection will take place on the outer Group (Group number 1):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupOptions.Retrieve;

Crpe1.GroupOptions[0].TopNOptions := tnTopN;

Crpe1.GroupOptions[0].TopNGroups := 10;

Crpe1.GroupOptions[0].TopNSortField :=

'Sum({company.SALES},{company.STATE})';

Crpe1.GroupOptions[0].TopNDiscardOthers := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


TopNSortField property

See also	Example

Applies to

GroupOptions

Declaration

property TopNSortField: string

Description

The TopNSortField property specifies the formula text of the expression that will control the TopN sorting/selection feature.

•	TopNSortField is normally a summary field, and has the same syntax and purpose as the Field property of  GroupSortFields.

•	TopNOptions must be set to one of the following in order for TopNSortField to take effect:  tnSorted, tnTopN, tnBottomN.

•	The TopNSortField value will cause any other GroupSortFields for the specified Group to be deleted when the Report is run.


TopNSortField property - See also
Related

TopNDiscardOthers

TopNGroups

TopNOptions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TopNSortField property - Example
Example

This example shows how to use the TopN features of GroupOptions.  In this case, the top 10 groups (based on the summary of their Sales) will be shown on the Report.  All other groups will be discarded.  The TopN selection will take place on the outer Group (Group number 1):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupOptions.Retrieve;

Crpe1.GroupOptions[0].TopNOptions := tnTopN;

Crpe1.GroupOptions[0].TopNGroups := 10;

Crpe1.GroupOptions[0].TopNSortField :=

'Sum({company.SALES},{company.STATE})';

Crpe1.GroupOptions[0].TopNDiscardOthers := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


TopNDiscardOthers property

See also	Example

Applies to

GroupOptions

Declaration

property TopNDiscardOthers: TCrBoolean

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The TopNDiscardOthers property determines if the TopN grouping will put all other Groups that are outside of the TopN/BottomN selection in a Group called "Others", or if they will be discarded.  If TopNDiscardOthers is set to cTrue, the other Groups will be discarded.


TopNDiscardOthers property - See also
Related

TopNGroups

TopNOptions

TopNSortField

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TopNDiscardOthers property - Example
Example

This example shows how to use the TopN features of GroupOptions.  In this case, the top 10 groups (based on the summary of their Sales) will be shown on the Report.  All other groups will be discarded.  The TopN selection will take place on the outer Group (Group number 1):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupOptions.Retrieve;

Crpe1.GroupOptions[0].TopNOptions := tnTopN;

Crpe1.GroupOptions[0].TopNGroups := 10;

Crpe1.GroupOptions[0].TopNSortField :=

'Sum({company.SALES},{company.STATE})';

Crpe1.GroupOptions[0].TopNDiscardOthers := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


ItemIndex property

See also	Example

Applies to

GroupOptions

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GroupOptions item number, or set the GroupOptions object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (GroupOptions[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the GroupOptions object is pointing to the first GroupOptions item:

if Crpe1.GroupOptions.ItemIndex <> 0 then

  Crpe1.GroupOptions[0];


Item property

See also	Example

Applies to

GroupOptions

Declaration

property Item[nIndex: integer]: TCrpeGroupOptions

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the GroupOptions object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  GroupOptions[2] is the same as GroupOptions.Item[2].

•	Item returns a reference to the GroupOptions object, so the GroupOptions properties can be used right after the subscript: GroupOptions[2].Direction := gdDescending;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupOptions.Retrieve;

{Set GroupOptions object to the 2nd item}

Crpe1.GroupOptions.Item[1];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupOptions.Retrieve;

{Set GroupOptions object to the 2nd item}

Crpe1.GroupOptions[1];


Retrieve method

See also	Example

Applies to

GroupOptions

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the GroupOptions information from the Report and stores it in the GroupOptions object.  If no GroupOptions information was found, the call returns False.  Be aware that calling Retrieve will first cause the GroupOptions object to be cleared, so any current information stored in it will be removed.

Note

Since the GroupOptions object also applies to Subreports, the Retrieve method will obtain the GroupOptions for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the GroupOptions information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate GroupOptions information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Add

Delete

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupOptions.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.GroupOptions.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Count method

See also	Example

Applies to

GroupOptions

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the GroupOptions object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GroupOptions.Retrieve;

  for cnt := 0 to (Crpe1.GroupOptions.Count - 1) do

    Crpe1.GroupOptions[cnt].KeepTogether := cTrue;

end;


Clear method

See also	Example

Applies to

GroupOptions

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GroupOptions object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the GroupOptions object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the GroupOptions of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the GroupOptions properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.GroupOptions.Clear;

This code clears the GroupOptions for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.GroupOptions.Clear;

end;


Add method

See also	Example

Applies to

GroupOptions

Declaration

function Add(GroupNumber: TCrGroupOptionsNumber): integer;

Type

TCrGroupOptionsNumber = integer;

Description

The Add method adds an item to the GroupOptions object and sets the internal index to that item.  It requires a Group number as a parameter, which should be a number corresponding to a Group in the Report.

Contrary to most other items in the Crystal VCL, Groups are numbered starting from one, so as to be consistent with the Group naming convention: GH1 is the first group header, etc (although the GroupOptions object is still zero based, so GroupOptions[0].Number is usually equal to 1).

The steps to using the Add method with GroupOptions are:

1. Add an item to the GroupOptions object (you must specify the Group Number).

2. Fill the item's properties (Field, Condition, etc.) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Group numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the GroupOptions object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Group Number - must be same as in Report}

Crpe1.GroupOptions.Add(1);

Crpe1.GroupOptions.KeepTogether := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


Delete method

See also	Example

Applies to

GroupOptions

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the GroupOptions object.  The "nIndex" parameter represents the order of the item in the GroupOptions object, which should not be confused with the Group Number value.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the GroupOptions object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Group Number - must be same as in Report}

Crpe1.GroupOptions.Add(1);

Crpe1.GroupOptions.KeepTogether := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;

{Specify the item number}

Crpe1.GroupOptions.Delete(0);


Send method

See also	Example

Applies to

GroupOptions

Declaration

function Send: boolean;

Description

The Send method sends the GroupOptions values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the GroupOptions settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.GroupOptions.Send;


Create method

See also

Applies to

GroupOptions

Declaration

constructor Create;

Description

The Create constructor creates the GroupOptions object.  It is used internally in the VCL component to create the GroupOptions object when the component is created, and should not be called outside of the component.


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

GroupOptions

Declaration

destructor Destroy; override;

Description

The Destroy method frees the GroupOptions object.  It is used internally in the VCL component to destroy the GroupOptions object when the component is destroyed, and should not be called outside of the component.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method

See also	Example

Applies to

GroupOptions

Declaration

procedure CopyFrom(Source: TCrpeGroupOptions);

Description

The CopyFrom method copies the GroupOptions property values from another TCrpeGroupOptions object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the GroupOptions property values to a temporary TCrpeGroupOptions object:

var

tempGroupOptions : TCrpeGroupOptions;

begin

tempGroupOptions := TCrpeGroupOptions.Create;

tempGroupOptions.CopyFrom(Crpe1.GroupOptions);

{...later, when finished with the temp object...}

tempGroupOptions.Free;

end;


ReportOptions

See also	Properties & Methods	Example

Declaration

property ReportOptions : TCrpeReportOptions;

Type

TCrpeReportOptions = class(TPersistent)

Description

Only available with SCR 7.0 and higher.  ReportOptions contains all the properties that reside in the "File | Report Options" dialog in Seagate Crystal Reports Designer.  These are options which are specific to a particular Report.  The ReportOptions object allows you to retrieve, modify, and send back the properties that belong to this class.

•	The CaseInsensitiveSQLData property specifies whether or not the SQL field names used in the Report will be treated with case-sensitivity or not.

•	The ConvertDateTimeType property specifies how DateTime fields will be treated in a Report: as DateTime values, as DateTime String values, or just as Date (no Time).

•	The ConvertNullFieldToDefault property specifies how Null field values will be treated in a Report: as they are (null), or as a default value (empty string for string fields, zero for numeric fields, etc.).  If Null fields are not converted to default, extra care must be taken in Formulas and Selection Formulas to test for Null values, otherwise a null value can cause a formula to stop processing as soon as the null is encountered.

•	The CreateGroupTree property determines if the GroupTree panel on the Preview Window will be available or not.

•	The PrintEngineErrorMessages property determines if the Print Engine will put up it's own error dialogs, on top of the VCL's error handling.  The built-in Print Engine error messages are often more descriptive than the standard error messages returned by the Print Engine to an application.  It may be desirable to turn this option on when doing development, but it normally should be turned off when the application is finally deployed.

•	The SaveDataWithReport property determines if a Report will save the actual data used from the database with the Report when the Report is saved.  Since saving is not possible at runtime, this property is not particularly useful at this time. It is possible to export a Report to RPT format, but the exported RPT will have Saved Data by default anyway.

•	The SaveSummariesWithReport property determines if the data calculated from summary fields in the Report is stored in the RPT file when the Report is saved. Since saving is not possible at runtime, this property is not particularly useful at this time.  It is possible to export a Report to RPT format, but the exported RPT will have Saved Data by default anyway.

•	The TranslateDOSMemos property determines how dBase memo fields with upper ASCII characters are handled, whether they are translated to corresponding ANSI character values, or not.

•	The TranslateDOSStrings property determines how dBase string fields with upper ASCII characters are handled, whether they are translated to corresponding ANSI character values, or not.

•	The UseIndexForSpeed property specifies if an index or a SQL Server will be used to speed up processing of a Record Selection.  Usually it is desirable to leave this option on, but it can cause problems with dBase indexes that use expressions or functions (which are not supported by Crystal's xBase driver).

•	The VerifyOnEveryPrint property determines whether the database structure will be re-read every time the Report runs.  It is useful to have this option turned on during development, where database field-types or lengths may change frequently.  If the database structure is fixed, and will not change, this option can be turned off for slightly faster processing of the Report.

•	The ZoomMode property determines which zoom level the Report will first appear in within the Preview Window.

•	The PerformGroupingOnServer property specifies whether the grouping of data for a Report will take place on the Server or not.  This option only applies to Reports based off an SQL or ODBC datasource.

•	The NoDataForHiddenObjects property determines whether data will be saved for parts of the Report that are in hidden sections.

•	The CopyFrom method can be used to store the ReportOptions settings to a temporary ReportOptions object.

•	The Retrieve method is used to retrieve the ReportOptions settings from a Report.

•	The Clear method can be used to set all the ReportOptions properties back to their default settings.


ReportOptions - See also
Related

WindowButtonBar

WindowZoom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ReportOptions - Properties & Methods
ReportOptions:

Properties & Methods

ReportOptions	TCrpe Component

Properties

CaseInsensitiveSQLData

ConvertDateTimeType

ConvertNullFieldToDefault

CreateGroupTree

NoDataForHiddenObjects

PerformGroupingOnServer

PrintEngineErrorMessages

SaveDataWithReport

SaveSummariesWithReport

TranslateDOSMemos

TranslateDOSStrings

UseIndexForSpeed

VerifyOnEveryPrint

ZoomMode

Methods

Clear

CopyFrom

Retrieve

Send

Constructor

Create


ReportOptions - Example
Example

This example sets the ReportOptions ZoomMode setting so that the Report will appear in the specified zoom when the Preview window appears:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.ZoomMode := pwWholePage;

Crpe1.Output := toWindow;

Crpe1.Execute;


CaseInsensitiveSQLData property

See also	Example

Applies to

ReportOptions

Declaration

property CaseInsensitiveSQLData: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The CaseInsensitiveSQLData property specifies whether or not the SQL field names used in the Report will be treated with case-sensitivity.


CaseInsensitiveSQLData property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CaseInsensitiveSQLData property - Example
Example

This example sets the CaseInsensitiveSQLData property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.CaseInsensitiveSQLData := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


ConvertDateTimeType property

See also	Example

Applies to

ReportOptions

Declaration

property ConvertDateTimeType: TCrDateTimeType;

Type

TCrDateTimeType = (dtConvertToString, dtConvertToDate, dtKeepAsDateTime, dtDefault);

Description

The ConvertDateTimeType property specifies how DateTime fields will be treated in a Report: as DateTime values, as DateTime String values, or just as Date (no Time).


ConvertDateTimeType property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ConvertDateTimeType property - Example
Example

This example sets the ConvertDateTimeType property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.ConvertDateTimeType := dtConvertToString;

Crpe1.Output := toWindow;

Crpe1.Execute;


ConvertNullFieldToDefault property

See also	Example

Applies to

ReportOptions

Declaration

property ConvertNullFieldToDefault: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The ConvertNullFieldToDefault property specifies how Null field values will be treated in a Report: as they are (null), or as a default value (empty string for string fields, zero for numeric fields, etc.).  If Null fields are not converted to default, extra care must be taken in Formulas and Selection Formulas to test for Null values, otherwise a null value can cause a formula to stop processing as soon as the null is encountered.


ConvertNullFieldToDefault property - See also
Related

Formulas

Selection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ConvertNullFieldToDefault property - Example
Example

This example sets the ConvertNullFieldToDefault property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.ConvertNullFieldToDefault := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


CreateGroupTree property

See also	Example

Applies to

ReportOptions

Declaration

property CreateGroupTree: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The CreateGroupTree property determines if the GroupTree panel on the Preview Window will be available or not.

This setting should be used in conjunction with the WindowButtonBar.GroupTree property:  if CreateGroupTree is cFalse, the WindowButtonBar.GroupTree will have no effect; if CreateGroupTree is cTrue, then WindowButtonBar.GroupTree can be used to control whether the GroupTree will appear or not.


CreateGroupTree property - See also
Related

GroupTree

WindowButtonBar

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CreateGroupTree property - Example
Example

This example sets the CreateGroupTree property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.CreateGroupTree := cTrue;

Crpe1.WindowButtonBar.GroupTree := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


NoDataForHiddenObjects property

See also	Example

Applies to

ReportOptions

Declaration

property NoDataForHiddenObjects: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The NoDataForHiddenObjects property determines whether data will be saved for parts of the Report that are in hidden sections.

This will mainly be of concern if a Report is being exported to Crystal Reports format, in which case it will have Saved Data.  This saved-data Report can be run from an application without having access to the original database, since all the data required to show the Report is saved with it.

When this exported Report is run later, it is possible to provide drill-down capability (WindowButtonBar.AllowDrillDown).  If that is done, it will be necessary for the Report to have saved data for the hidden sections, so that the drill down will not cause the Report to attempt to read the database.  So, before exporting the Report, make sure NoDataForHiddenObjects is set to cFalse.

On the other hand, if drill-down will not be offered, make sure NoDataForHiddenObjects is set to cTrue, so that the resulting exported RPT's file size will be smaller.


NoDataForHiddenObjects property - See also
Related

SaveDataWithReport

SaveSummariesWithReport

DiscardSavedData

HasSavedData

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NoDataForHiddenObjects property - Example
Example

This example sets the NoDataForHiddenObjects property of ReportOptions so that an exported RPT will have Saved Data for all objects in all sections of the Report, even the hidden ones:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.NoDataForHiddenObjects := cFalse;

{This next one is just a formality: all exported RPT have Saved Data}

Crpe1.ReportOptions.SaveDataWithReport := cTrue;

{Save Summaries also: optional}

Crpe1.ReportOptions.SaveSummariesWithReport := cTrue;

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := CrystalReportRPT;

Crpe1.Export.FileName := 'C:\SavedData.rpt';

Crpe1.Execute;


PerformGroupingOnServer property

See also	Example

Applies to

ReportOptions

Declaration

property PerformGroupingOnServer: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The PerformGroupingOnServer property specifies whether the grouping of data for a Report will take place on the Server or not.  This option only applies to Reports based off an SQL or ODBC datasource.


PerformGroupingOnServer property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PerformGroupingOnServer property - Example
Example

This example sets the PerformGroupingOnServer property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.PerformGroupingOnServer := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


PrintEngineErrorMessages property

See also	Example

Applies to

ReportOptions

Declaration

property PrintEngineErrorMessages: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The PrintEngineErrorMessages property determines if the Print Engine will put up it's own error dialogs, on top of the VCL's error handling.  The built-in Print Engine error messages are often more descriptive than the standard error messages returned by the Print Engine to an application.  It may be desirable to turn this option on when doing development, but it normally should be turned off when the application is finally deployed.


PrintEngineErrorMessages property - See also
Related

OnError

LastErrorNumber

LastErrorString

Error Numbers & Strings

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintEngineErrorMessages property - Example
Example

This example sets the PrintEngineErrorMessages property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.PrintEngineErrorMessages := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


SaveDataWithReport property

See also	Example

Applies to

ReportOptions

Declaration

property SaveDataWithReport: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The SaveDataWithReport property determines if a Report will save the actual data used from the database with the Report when the Report is saved.  Since saving is not possible at runtime, this property is not particularly useful at this time. It is possible to export a Report to RPT format, but the exported RPT will have Saved Data by default anyway.


SaveDataWithReport property - See also
Related

NoDataForHiddenObjects

SaveSummariesWithReport

DiscardSavedData

HasSavedData

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SaveDataWithReport property - Example
Example

This example sets the SaveDataWithReport property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

{Save Data for Subreports, etc. in hidden sections}

Crpe1.ReportOptions.NoDataForHiddenObjects := cFalse;

{This next one is just a formality: all exported RPT have Saved Data}

Crpe1.ReportOptions.SaveDataWithReport := cTrue;

{Save Summaries also: optional}

Crpe1.ReportOptions.SaveSummariesWithReport := cTrue;

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := CrystalReportRPT;

Crpe1.Export.FileName := 'C:\SavedData.rpt';

Crpe1.Execute;


SaveSummariesWithReport property

See also	Example

Applies to

ReportOptions

Declaration

property SaveSummariesWithReport: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The SaveSummariesWithReport property determines if the data calculated from summary fields in the Report is stored in the RPT file when the Report is saved.  Since saving is not directly possible at runtime, this property is only useful when a Report is exported to RPT format.

Note

If SaveSummariesWithReport is set to cTrue, SaveDataWithReport must be set to cTrue as well, or an error will result.


SaveSummariesWithReport property - See also
Related

NoDataForHiddenObjects

SaveDataWithReport

DiscardSavedData

HasSavedData

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SaveSummariesWithReport property - Example
Example

This example sets the SaveSummariesWithReport property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

{Save Data for Subreports, etc. in hidden sections}

Crpe1.ReportOptions.NoDataForHiddenObjects := cFalse;

{This next one is just a formality: all exported RPT have Saved Data}

Crpe1.ReportOptions.SaveDataWithReport := cTrue;

{Save Data calculated in Summaries}

Crpe1.ReportOptions.SaveSummariesWithReport := cTrue;

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := CrystalReportRPT;

Crpe1.Export.FileName := 'C:\SavedData.rpt';

Crpe1.Execute;


TranslateDOSMemos property

See also	Example

Applies to

ReportOptions

Declaration

property TranslateDOSMemos: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The TranslateDOSMemos property determines how dBase memo fields with upper ASCII characters are handled, whether they are translated to corresponding ANSI character values, or not.


TranslateDOSMemos property - See also
Related

TranslateDOSStrings

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TranslateDOSMemos property - Example
Example

This example sets the TranslateDOSMemos property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.TranslateDOSMemos := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


TranslateDOSStrings property

See also	Example

Applies to

ReportOptions

Declaration

property TranslateDOSStrings: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The TranslateDOSStrings property determines how dBase string fields with upper ASCII characters are handled, whether they are translated to corresponding ANSI character values, or not.


TranslateDOSStrings property - See also
Related

TranslateDOSMemos

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TranslateDOSStrings property - Example
Example

This example sets the TranslateDOSStrings property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.TranslateDOSStrings := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


UseIndexForSpeed property

See also	Example

Applies to

ReportOptions

Declaration

property UseIndexForSpeed: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The UseIndexForSpeed property specifies if an index or a SQL Server will be used to speed up processing of a Record Selection.  Usually it is desirable to leave this option on, but it can cause problems with dBase indexes that use expressions or functions (which are not supported by Crystal's xBase driver).


UseIndexForSpeed property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


UseIndexForSpeed property - Example
Example

This example turns off the UseIndexForSpeed property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.UseIndexForSpeed := cFalse;

Crpe1.Output := toWindow;

Crpe1.Execute;


VerifyOnEveryPrint property

See also	Example

Applies to

ReportOptions

Declaration

property VerifyOnEveryPrint: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The VerifyOnEveryPrint property determines whether the database structure will be re-read every time the Report runs.  It is useful to have this option turned on during development, where database field-types or lengths may change frequently.  If the database structure is fixed, and will not change, this option can be turned off for slightly faster processing of the Report.

Note

For PC-type databases: it may be useful to turn this property on, or use the VerifyDatabase method, when pointing a Report that uses linked tables, to new tables with different names, so that the linking and index information gets updated correctly.


VerifyOnEveryPrint property - See also
Related

VerifyDatabase

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


VerifyOnEveryPrint property - Example
Example

This example sets the VerifyOnEveryPrint property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.VerifyOnEveryPrint := cTrue;

Crpe1.Output := toWindow;

Crpe1.Execute;


ZoomMode property

See also	Example

Applies to

ReportOptions

Declaration

property ZoomMode: TCrZoomPreview;

Type

TCrZoomPreview = (pwNormal, pwPageWidth, pwWholePage, pwDefault);

Description

The ZoomMode property controls the zoom level of the Crystal Preview Window when it first appears on screen:

pwNormal	= Equivalent to 100% magnification.

pwPageWidth	= The Report will be sized to fit the width of the Preview Window.

pwWholePage	= The Report will be sized to fit the width and height of the Preview Window.

pwDefault	= The ZoomMode property is ignored.  The zoom level will be determined by the level the Report was saved with, or the setting of the WindowZoom.Preview or WindowZoom.Magnification properties.


ZoomMode property - See also
Related

WindowZoom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ZoomMode property - Example
Example

This example sets the ZoomMode property of ReportOptions:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.ZoomMode := pwWholePage;

Crpe1.WindowState := wsMaximized;

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

ReportOptions

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the ReportOptions object, and does not need to be called in code, unless you are using the CopyFrom method to store ReportOptions data to a temporary object:

var

  tempReportOptions : TCrpeReportOptions;

begin

  tempReportOptions := TCrpeReportOptions.Create;

  tempReportOptions.CopyFrom(Crpe1.ReportOptions);

end;


Create method - See also
Related

CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method

See also	Example

Applies to

ReportOptions

Declaration

procedure CopyFrom(Source: TCrpeReportOptions);

Description

The CopyFrom method copies the ReportOptions property values from another TCrpeReportOptions object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the ReportOptions property values to a temporary TCrpeReportOptions object:

var

tempReportOptions : TCrpeReportOptions;

begin

tempReportOptions := TCrpeReportOptions.Create;

tempReportOptions.CopyFrom(Crpe1.ReportOptions);

{...later, when finished with the temp object...}

tempReportOptions.Free;

end;


Retrieve method

See also	Example

Applies to

ReportOptions

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the ReportOptions information from the Report and stores it in the ReportOptions object.  If ReportOptions information was not found, the call returns False.


Retrieve method - See also
Related

Clear

Send

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method.  ReportOptions belong to the main Report, therefore it is not necessary to retrieve them from Subreports also:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportOptions.Retrieve;


Send method

See also	Example

Applies to

ReportOptions

Declaration

function Send: boolean;

Description

The Send method sends the ReportOptions values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the ReportOptions settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.ReportOptions.Send;


Clear method

See also	Example

Applies to

ReportOptions

Declaration

procedure Clear;

Description

The Clear method can be used to set the ReportOptions properties back to their default values:

CaseInsensitiveSQLData 	:= cDefault;

ConvertDateTimeType 	:= dtDefault;

ConvertNullFieldToDefault	:= cDefault;

CreateGroupTree 	:= cDefault;

NoDataForHiddenObjects 	:= cDefault;

PerformGroupingOnServer 	:= cDefault;

PrintEngineErrorMessages	:= cDefault;

SaveDataWithReport 	:= cDefault;

SaveSummariesWithReport 	:= cDefault;

TranslateDOSMemos 	:= cDefault;

TranslateDOSStrings 	:= cDefault;

UseIndexForSpeed 	:= cDefault;

VerifyOnEveryPrint 	:= cDefault;

ZoomMode 	:= pwDefault;

It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as needed.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This line of code clears the ReportOptions properties:

Crpe1.ReportOptions.Clear;


Expressions

See also	Properties & Methods	Example

Declaration

property Expressions : TCrpeSQLExpressions;

Type

TCrpeSQLExpressions = class(TPersistent)

Description

Only available with SCR 7 and higher. The Expressions object contains all the properties that apply to SQL Expressions in a Report.

•	The Name property specifies the Name of the Expression.

•	The Expression property holds the Expression text.

•	The default array property Item, and the ItemIndex property, can be used to navigate through the various Expressions that may be stored in the Expressions object.

•	Expressions may be retrieved from the Report via the Retrieve method.

•	The Add / Delete methods can be used instead of Retrieve/Clear to manually add and remove items in the Expressions object.

•	The Check method provides an easy way of checking the syntax of the Expression text before running the Report.

SQL Expressions are similar to Crystal Reports Formulas, except that they use SQL syntax, and are processed on the Server (whenever possible).


Expressions - See also
Related

SQL

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Expressions - Properties & Methods
Expressions:

Properties & Methods

Expressions	TCrpe Component

Properties

Expression

Key

Name

Navigation

Item

ItemIndex

Methods

Check

Clear

CopyFrom

Count

IndexOf

Retrieve

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


Expressions - Example
Example

The following code retrieves the Expressions from a Report, and sets the first one:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Expressions.Retrieve;

{Assign a new expression to the Expression property}

Crpe1.SQL.Expressions[0].Expression.Text := '{fn RTRIM(company.`name`)}';

Crpe1.Output := toWindow;

Crpe1.Execute;


Expression property

See also	Example

Applies to

Expressions

Declaration

property Expression: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The Expression property contains the actual text of the Expression.  To assign a new value to the Expression property, any of the following methods can be used (or any other method that is valid for a StringList):

1) Crpe1.SQL.Expressions.Expression.Assign('{fn UCASE(table.`lastname`)}');

2) Crpe1.SQL.Expressions.Expression.Text := '{fn UCASE(table.`lastname`)}';

3) Crpe1.SQL.Expressions.Expression.Clear;

   Crpe1.SQL.Expressions.Expression[0] := '{fn UCASE(table.`lastname`)}';

4) Crpe1.SQL.Expressions.Expression.SetText(PChar('{fn UCASE(table.`lastname`)}'));

•	The new Expression string must conform to SQL syntax requirements.


Expression property - See also
Related

Name

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Expression property - Example
Example

The following code shows how the Expression property is used to store a new expression:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Expressions.Retrieve;

Crpe1.SQL.Expressions[0].Expression.Assign('{fn UCASE(employee.`lastname`)}');

Crpe1.Output := toWindow;

Crpe1.Execute;


Item property

See also	Example

Applies to

Expressions

Declaration

property Item[const nIndex: integer]: TCrpeSQLExpressions;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the Expressions object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  Expressions[2] is the same as Expressions.Item[2].

•	Item returns a reference to the Expressions object, so the Expressions properties can be used right after the subscript: Expressions[2].Name := 'Expression1';


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Expressions.Retrieve;

{Set Expressions to the 3rd Expression}

Crpe1.SQL.Expressions.Item[2];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Expressions.Retrieve;

{Set Expressions to the 3rd Expression}

Crpe1.SQL.Expressions[2];


ItemIndex property

See also	Example

Applies to

Expressions

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current Expressions item number, or set the Expressions object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (Expressions[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Expressions.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the Expressions object is pointing to the first Expression:

if Crpe1.SQL.Expressions.ItemIndex <> 0 then

  Crpe1.SQL.Expressions[0];


Name property

See also	Example

Applies to

Expressions

Declaration

property Name: TCrExpressionName;

Type

TCrExpressionName = string;

Description

The Name property specifies the Name of the Expression.  It is a key property, and therefore serves as a lookup; that is, assigning it a value will cause the Expressions object to point to the item that has a Expression Name with the same value.  Before using the Name property to navigate through the Expressions, the Retrieve method should be called, or the manual Add method.

•	The % sign is not used when designating an Expression name in this property.

•	This property cannot be used to create new Expressions. Only Expressions that already exist in the Report can be specified.


Name property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Name property - Example
Example

The following code uses the Expression Name property to point the Expressions object to the specified expression.  It then assigns a new expression text to the Expression property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Expressions.Retrieve;

{Set the Expressions object to the "Expression One" item}

Crpe1.SQL.Expressions.Name := 'Expression One';

{Assign a new expression to the Expression property}

Crpe1.SQL.Expressions.Expression.Text := '{fn RTRIM(company.`name`)}';

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

Expressions

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Expressions object, and does not need to be called in code, unless you are using the CopyFrom method to store Expressions data to a temporary object:

var

  tempExpressions : TCrpeExpressions;

begin

  tempExpressions := TCrpeExpressions.Create;

  tempExpressions.CopyFrom(Crpe1.SQL.Expressions);

end;


Create method - See also
Related

CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

Expressions

Declaration

destructor Destroy;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
Related

Create

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Check method

See also	Example

Applies to

Expressions

Declaration

function Check: boolean;

Description

The Check method can be used to check the syntax of an Expression before running the Report.  Check returns a boolean value:

True	: Expression is good.

False	: Expression has an error.


Check method - See also
Related

Expression

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Check method - Example
Example

The following code loops through all the Expressions, checking each one:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Expressions.Retrieve;

for cnt := 0 to (Crpe1.SQL.Expressions.Count - 1) do

begin

  if not Crpe1.SQL.Expressions[cnt].Check then

    ShowMessage('Error in Expression #' + IntToStr(cnt));

end;

end;


CopyFrom method

See also	Example

Applies to

Expressions

Declaration

procedure CopyFrom(Source: TCrpeSQLExpressions);

Description

The CopyFrom method copies the Expressions property values from another TCrpeSQLExpressions object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Expressions property values to a temporary TCrpeSQLExpressions object:

var

tempExpressions : TCrpeSQLExpressions;

begin

tempExpressions := TCrpeSQLExpressions.Create;

tempExpressions.CopyFrom(Crpe1.SQL.Expressions);

{...later, when finished with the temp object...}

tempExpressions.Free;

end;


Count method

See also	Example

Applies to

Expressions

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the Expressions object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.SQL.Expressions.Retrieve;

  for cnt := 0 to (Crpe1.SQL.Expressions.Count - 1) do

  begin

    if not Crpe1.SQL.Expressions[cnt].Check then

        ShowMessage('Error in Expression: ' + IntToStr(cnt));

  end;

end;


IndexOf method

See also	Example

Applies to

Expressions

Declaration

function IndexOf(ExpressionName: TCrExpressionName): integer;

Type

TCrExpressionName = string;

Description

The IndexOf method takes an Expression name and returns the index position of the Expression item in the current Expressions object.

After the Retrieve method has been called, the Expressions object contains one item for each Expression in the Report.  The IndexOf method can be used to determine if a given Expression Name actually exists in the Expressions object before trying to access it.


IndexOf method - See also
Related

Name

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

The following code illustrates the use of the IndexOf method to locate a specific Expression item by it's name:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Expressions.Retrieve;

{Find a specific Expression}

nItem := Crpe1.SQL.Expressions.IndexOf('Expression1');

{If it exists, change the Expression}

if nItem > -1 then

Crpe1.SQL.Expressions[nItem].Expression.Text := '{fn UCASE(employee.`lastname`)}';

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Retrieve method

See also	Example

Applies to

Expressions

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SQL Expressions information from the Report and stores it in the Expressions object.  If no Expressions information was found, the call returns False.  Be aware that calling Retrieve will first cause the Expressions object to be cleared, so any current information stored in it will be removed.

Note

Since the Expressions object also applies to Subreports, the Retrieve method will obtain the Expressions for the Report (or Subreport) that the Subreports object index is currently pointing to.  If you want to obtain the Expressions information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item.  The VCL will store separate Expressions information for each Subreport (see Example).


Retrieve method - See also
Related

Clear

Send

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SQL.Expressions.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

  begin

    Crpe1.Subreports[cnt];

    Crpe1.SQL.Expressions.Retrieve;

  end;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Send method

See also	Example

Applies to

Expressions

Declaration

function Send: boolean;

Description

The Send method sends the Expressions values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the Expressions settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SQL.Expressions.Send;


Add method

See also	Example

Applies to

Expressions

Declaration

function Add(ExpressionName: TCrExpressionName): integer;

Type

TCrExpressionName = string;

Description

The Add method manually adds an item to the Expressions object and sets the internal index to that item.  It requires an Expression name as a parameter, which should be a name corresponding to an Expression already created in the Report.

The steps to using the Add method with Expressions are:

1. Add an item to the Expressions object (you must specify the Expression Name).

2. Fill the item's Expression property with a value.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Expression names are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the Expressions object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Expression Name - must be same as in Report}

Crpe1.SQL.Expressions.Add('Expression1');

Crpe1.SQL.Expressions.Expression.Text := '{fn UCASE(employee.`lastname`)}';

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

Expressions

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the Expressions object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the Expressions object of the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the Expressions of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the Expressions for the main Report (assuming the default state of Subreports[0]):

Crpe1.SQL.Expressions.Clear;

This code clears the Expressions for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

begin

  Crpe1.Subreports[cnt];

  Crpe1.SQL.Expressions.Clear;

end;


Delete method

See also	Example

Applies to

Expressions

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the Expressions object.  The "nIndex" parameter represents the order of the item in the Expressions object.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the Expressions object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Expression Name - must be same as in Report}

Crpe1.SQL.Expressions.Add('Expression1');

Crpe1.SQL.Expressions.Expression.Text := '{fn UCASE(employee.`lastname`)}';

Crpe1.Output := toWindow;

Crpe1.Execute;

{Specify the item number}

Crpe1.SQL.Expressions.Delete(0);


Excel

See also	Properties & Methods	Example

Applies to

Export

Declaration

property Excel: TCrpeExportExcel;

Type

TCrpeExportExcel = class(TPersistent)

Description

The Excel object contains the properties that apply when exporting a Report to Excel.  Excel format 5 and upward are only available to users of Seagate Crystal Reports 7 and up.

•	The XlsType property determines the actual Excel format, from Excel2 to Excel8Tab.

•	The ColumnHeadings property determines if the exported Excel File will have Column Headings or not.

•	The ColumnWidth property determines how the column width is calculated on a Report exported to Excel5Extended.  If it is set to ByArea, then the column width is determined by the Area property setting.  If it is set to ByConstant, then the column width is determined by the Constant property setting.  Area allows Crystal to set the width based on the objects in a certain Report area; Constant allows the programmer to hard-code a column width value.

•	The Area property specifies the Report Section whose objects will be used to determine the column widths of the exported Excel file (if ColumnWidth is set to ByArea).

•	The Constant property determines the column width on a Report exported to Excel5Extended if ColumnWidth is set to ByConstant.

•	The TabularFormat property determines if all the objects in one area in a Report will be arranged into one row (when TabularFormat is True), or whether they will be split into separate rows (when TabularFormat is False).

•	The WorksheetFunctions property determines if the subtotal fields in an exported Report will be represented by Excel worksheet functions.

•	The Clear method can be used to set the Excel5Ext object back to it's default property values.

•	The CopyFrom method can be used to copy the Excel5Ext property values to another Excel5Ext object (for temporary storage).

Note

Excel2 to Excel5 do not support any of the other options exposed in the Excel properties.  Area, ColumnHeadings, ColumnWidth, Constant, TabularFormat, and WorksheetFunctions are only supported in Excel5Extended and higher.


Excel - See also
Related

Export

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Excel - Properties & Methods
Excel:

Properties & Methods

Excel	TCrpe Component

Properties

Area

ColumnHeadings

ColumnWidth

Constant

TabularFormat

WorksheetFunctions

XlsType

Methods

Clear

CopyFrom

Constructor

Create


Excel - Example
Example

Exporting to File in Excel format:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := ExcelXLS;

Crpe1.Export.Excel.XlsType := Excel8Tab;

Crpe1.Export.Excel.ColumnHeadings := True;

Crpe1.Export.Excel.ColumnWidth := ByArea;

Crpe1.Export.Excel.Area := 'D';

Crpe1.Export.Excel.TabularFormat := True;

Crpe1.Execute;


Area property

See also	Example

Applies to

Excel

Declaration

property Area: string;

Description

The Area property specifies the Report Section whose objects will be used to determine the column widths of the exported Excel file.  The ColumnWidth property must also be set to ByArea for this property to have effect.

The Area name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.

The default setting for the Area property is "D" (Details).


Area property - See also
Related

ColumnWidth

Constant

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Area property - Example
Example

Exporting to File in Excel format.  The Column Width is determined by the Details area of the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := ExcelXLS;

Crpe1.Export.Excel.XlsType := Excel5Extended;

Crpe1.Export.Excel.ColumnHeadings := True;

Crpe1.Export.Excel.ColumnWidth := ByArea;

Crpe1.Export.Excel.Area := 'D';

Crpe1.Export.Excel.TabularFormat := True;

Crpe1.Execute;


ColumnHeadings property

See also	Example

Applies to

Excel

Declaration

property ColumnHeadings: boolean;

Description

Setting ColumnHeadings to True will cause the exported Excel spreadsheet to have Column Headings (you probably figured that out!).


ColumnHeadings property - See also
Related

TabularFormat

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ColumnHeadings property - Example
Example

Exporting to File in Excel format with column headings:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := ExcelXLS;

Crpe1.Export.Excel.XlsType := Excel5Extended;

Crpe1.Export.Excel.ColumnHeadings := True;

Crpe1.Export.Excel.ColumnWidth := ByArea;

Crpe1.Export.Excel.Area := 'D';

Crpe1.Export.Excel.TabularFormat := True;

Crpe1.Execute;


ColumnWidth property

See also	Example

Applies to

Excel

Declaration

property ColumnWidth: TCrColumnWidth;

Type

TCrColumnWidth = (ByArea, ByConstant);

Description

ColumnWidth determines how the column width is calculated on a Report exported to Excel.  If it is set to ByArea, then the column width is determined by the Area property setting.  If it is set to ByConstant, then the column width is determined by the Constant property setting.  Area allows Crystal to set the width based on the objects in a certain Report area; Constant allows the programmer to hard-code a column width value.


ColumnWidth property - See also
Related

Area

Constant

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ColumnWidth property - Example
Example

Exporting to File in Excel format.  The Column Width is determined by the Details area of the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := ExcelXLS;

Crpe1.Export.Excel.XlsType := Excel5Extended;

Crpe1.Export.Excel.ColumnHeadings := True;

Crpe1.Export.Excel.ColumnWidth := ByArea;

Crpe1.Export.Excel.Area := 'D';

Crpe1.Export.Excel.TabularFormat := True;

Crpe1.Execute;

Exporting to File in Excel format.  The Column Width is determined by the value of the Constant property, in this case, 12:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := ExcelXLS;

Crpe1.Export.Excel.XlsType := Excel5Extended;

Crpe1.Export.Excel.ColumnHeadings := True;

Crpe1.Export.Excel.ColumnWidth := ByConstant;

Crpe1.Export.Excel.Constant := 12;

Crpe1.Export.Excel.TabularFormat := True;

Crpe1.Execute;


Constant property

See also	Example

Applies to

Excel

Declaration

property Constant: double;

Description

If the ColumnWidth property is set to ByConstant, the Constant property determines the column width on a Report exported to Excel.  The default setting for the Constant property is 9.


Constant property - See also
Related

ColumnWidth

Area

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Constant property - Example
Example

Exporting to File in Excel format.  The Column Width is determined by the value of the Constant property, in this case, 12:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := ExcelXLS;

Crpe1.Export.Excel.XlsType := Excel5Extended;

Crpe1.Export.Excel.ColumnHeadings := True;

Crpe1.Export.Excel.ColumnWidth := ByConstant;

Crpe1.Export.Excel.Constant := 12;

Crpe1.Export.Excel.TabularFormat := True;

Crpe1.Execute;


TabularFormat property

See also	Example

Applies to

Excel

Declaration

property TabularFormat: boolean;

Description

The TabularFormat property determines if all the objects in one area in a Report will be arranged into one row (when TabularFormat is True), or whether they will be split into separate rows (when TabularFormat is False).


TabularFormat property - See also
Related

ColumnHeadings

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TabularFormat property - Example
Example

Exporting to File in Excel5Extended format with tabular format active:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := ExcelXLS;

Crpe1.Export.Excel.XlsType := Excel5Extended;

Crpe1.Export.Excel.ColumnHeadings := True;

Crpe1.Export.Excel.ColumnWidth := ByArea;

Crpe1.Export.Excel.Area := 'D';

Crpe1.Export.Excel.TabularFormat := True;

Crpe1.Execute;


Create method

See also

Applies to

Excel

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Excel object, and does not need to be called in code, unless you are using the CopyFrom method to store Excel data to a temporary object:

var

  tempExcel : TCrpeExportExcel;

begin

  tempExcel := TCrpeExportExcel.Create;

  tempExcel.CopyFrom(Crpe1.Export.Excel);

end;


Create method - See also
Related

CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method

See also	Example

Applies to

Excel

Declaration

procedure CopyFrom(Source: TCrpeExportExcel);

Description

The CopyFrom method copies the Excel property values from another TCrpeExportExcel object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Excel property values to a temporary TCrpeExportExcel object:

var

tempExcel : TCrpeExportExcel;

begin

tempExcel := TCrpeExportExcel.Create;

tempExcel.CopyFrom(Crpe1.Export.Excel);

{...later, when finished with the temp object...}

tempExcel.Free;

end;


Clear method

See also	Example

Applies to

Excel

Declaration

procedure Clear;

Description

This method can be used to set the properties of the Excel object back to their default values:

  Area           := 'D';

  ColumnHeadings := False;

  ColumnWidth    := ByArea;

  Constant       := 9;

  TabularFormat  := False;

  WorksheetFunctions := True;

  XlsType        := Excel5Extended;

It is called automatically if the Clear method is called for the main component, but may be called in code as desired.


Clear method - See also
Related

TCrpe.Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code sets the Excel properties back to default:

Crpe1.Export.Excel.Clear;


WorksheetFunctions property

See also	Example

Applies to

Excel

Declaration

property WorksheetFunctions: boolean;

Description

The WorksheetFunctions property determines if the subtotal fields in an exported Report will be represented by Excel worksheet functions.  The default setting for WorksheetFunctions is True.


WorksheetFunctions property - See also
Related

XlsType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


WorksheetFunctions property - Example
Example

Exporting to File in Excel5Extended format with tabular format active:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := ExcelXLS;

Crpe1.Export.Excel.XlsType := Excel5Extended;

Crpe1.Export.Excel.ColumnHeadings := True;

Crpe1.Export.Excel.ColumnWidth := ByArea;

Crpe1.Export.Excel.Area := 'D';

Crpe1.Export.Excel.TabularFormat := True;

Crpe1.Export.Excel.WorksheetFunctions := True;

Crpe1.Execute;


XlsType property

See also	Example

Applies to

Excel

Declaration

property XlsType: TCrExportExcelType;

Type

TCrExportExcelType = (Excel2, Excel3, Excel4, Excel5, Excel5Extended, Excel7, Excel7Tab, Excel8, Excel8Tab);

Description

The XlsType property determines which Excel format the exported Report will be in.

Note

Excel2 to Excel5 do not support any of the other options exposed in the Excel properties.  Area, ColumnHeadings, ColumnWidth, Constant, TabularFormat, and WorksheetFunctions are only supported in Excel5Extended and higher.


XlsType property - See also
Related

WorksheetFunctions

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


XlsType property - Example
Example

Exporting to File in Excel5Extended format with tabular format active:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := ExcelXLS;

Crpe1.Export.Excel.XlsType := Excel5Extended;

Crpe1.Export.Excel.ColumnHeadings := True;

Crpe1.Export.Excel.ColumnWidth := ByArea;

Crpe1.Export.Excel.Area := 'D';

Crpe1.Export.Excel.TabularFormat := True;

Crpe1.Execute;


Info

See also	Properties & Methods	Example

Applies to

ParamFields

Declaration

property Info : TCrpeParamFieldInfo;

Type

TCrpeParamFieldInfo = class(TPersistent)

Description

Only available with Seagate Crystal Reports 7 and higher.  The Info sub-class contains 7 properties that refer to extra Parameter Field options.

•	The AllowEditing property determines if the Parameter Field can be edited in the Prompt Dialog.

•	The AllowMultipleValues property determines if the Parameter Field will accept more than one value.

•	The AllowNull property determines if the Parameter Field will accept a null value; that is, whether it can be left blank in the Prompt Dialog.  This property only applies to Stored Procedure Parameters, which are now read through the ParamFields object, instead of SQL.Params as with former versions of Crystal Reports.

•	The PartOfGroup property determines if the Parameter Field is grouped with other Parameter Fields.  If it is, it will appear on the same tab of the Prompt Dialog as the other Parameters it is grouped with.

•	The GroupNum property specifies the Group number that the Parameter Field belongs to.  This only applies if PartOfGroup is set to cTrue.

•	The MutuallyExclusiveGroup property goes along with the previous two properties, and determines if a Grouped Parameter Field will be mutually exclusive.  A Parameter is mutually exclusive if when selecting one of it's values, the other Parameters in the Group are de-selected.

•	The ValueType property specifies whether the Parameter Field uses Discrete values or Ranges.

•	The Retrieve method will fetch the Parameter Field Info for the current Parameter specified in the ParamField object, and will set the Info properties accordingly.

•	The Clear method will set the Info properties to default values.

•	The CopyFrom method will copy the Info property values from another Info object.


Info - See also
Related

ParamFields

Ranges

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Info - Properties & Methods
Info:

Properties & Methods

Info	TCrpe Component

Properties

AllowEditing

AllowMultipleValues

 	AllowNull

GroupNum

MutuallyExclusiveGroup

PartOfGroup

ValueType

Methods

Clear

CopyFrom

Retrieve

Send

Constructor

Create


Info - Example
Example

This example retrieves the ParamFields values from the Report, and sets the first ParamField to allow editing, and to disallow multiple values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Info.AllowEditing := cTrue;

Crpe1.ParamFields[0].Info.AllowMultipleValues := cFalse;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


AllowEditing property

See also	Example

Applies to

Info

Declaration

property AllowEditing: TCrBoolean;

Description

This property determines if the Parameter Field can be edited in the Prompt Dialog.  If it is set to cFalse, the user will have to choose one of the DefaultValues from the drop-down list in the Parameter Field Prompt Dialog.


AllowEditing property - See also
Related

AllowMultipleValues

AllowNull

ParamFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AllowEditing property - Example
Example

This example retrieves the ParamFields values from the Report, and sets the first ParamField to allow editing, and to disallow multiple values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Info.AllowEditing := cTrue;

Crpe1.ParamFields[0].Info.AllowMultipleValues := cFalse;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


AllowMultipleValues property

See also	Example

Applies to

Info

Declaration

property AllowMultipleValues: TCrBoolean;

Description

This property determines if the Parameter Field will accept more than one value.  If it is set to cTrue, an extra ListBox will appear in the Prompt Dialog to which the user can add multiple values to be sent into the Parameter.  When multiple values are passed into a Parameter Field, the Parameter is treated as an array of values, as in this example:

["Smith", "Jones", "Brown"]


AllowMultipleValues property - See also
Related

AllowEditing

AllowNull

ParamFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AllowMultipleValues property - Example
Example

This example retrieves the ParamFields values from the Report, and sets the first ParamField to allow editing, and to disallow multiple values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Info.AllowEditing := cTrue;

Crpe1.ParamFields[0].Info.AllowMultipleValues := cFalse;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


AllowNull property

See also	Example

Applies to

Info

Declaration

property AllowNull: TCrBoolean;

Description

This property specifies whether the Parameter Field will accept a null value; that is, whether it can be left blank in the Prompt Dialog.   This property only applies to Stored Procedure Parameters, which from Crystal Reports 7 and up, are now read through the ParamFields object, instead of SQL.Params (as with Crystal Reports 6 and lower).


AllowNull property - See also
Related

AllowEditing

AllowMultipleValues

ParamFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


AllowNull property - Example
Example

This example retrieves the ParamFields values from the Report, and sets the first ParamField to allow editing, and to disallow multiple values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Info.AllowEditing := cTrue;

Crpe1.ParamFields[0].Info.AllowMultipleValues := cFalse;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


GroupNum property

See also	Example

Applies to

Info

Declaration

property GroupNum: smallint;

Description

The GroupNum property specifies the Group that the Parameter Field belongs to.  This only applies if PartOfGroup is set to cTrue.

Notes on Grouping

Grouping of Parameters only applies to Boolean Parameter Fields.  With Grouping, multiple Boolean Parameter Fields can be treated as a Group, whereby they will all appear on the same tab of the Parameter Field prompt dialog.  The PartOfGroup property turns the grouping feature on or off for a Parameter Field.  The GroupNum property determines which Group a grouped Parameter belongs to.

Grouped Parameters will be presented in a drop-down list.  If MutuallyExclusiveGroup is set to cFalse, more than one item can be selected from the drop-down list and added to a listbox.  All Parameters added to the listbox will have a True value, all those not in the listbox will have a False value.  If MutuallyExclusiveGroup is set to cTrue, then only the Parameter selected in the drop-down list will have a True value, and all other Boolean Parameters in that Group will have a False value.


GroupNum property - See also
Related

MutuallyExclusiveGroup

PartOfGroup

ParamFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GroupNum property - Example
Example

This example retrieves the ParamFields values from the Report, and sets the first ParamField to allow editing, and to disallow multiple values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Info.AllowEditing := cTrue;

Crpe1.ParamFields[0].Info.AllowMultipleValues := cFalse;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


MutuallyExclusiveGroup property

See also	Example

Applies to

Info

Declaration

property MutuallyExclusiveGroup: TCrBoolean;

Description

This property determines if a Grouped Parameter Field will be mutually exclusive.  A Parameter is mutually exclusive if only one member of the Group can be selected, and when selecting it, the other Parameters in the Group are de-selected.

Notes on Grouping

Grouping of Parameters only applies to Boolean Parameter Fields.  With Grouping, multiple Boolean Parameter Fields can be treated as a Group, whereby they will all appear on the same tab of the Parameter Field prompt dialog.  The PartOfGroup property turns the grouping feature on or off for a Parameter Field.  The GroupNum property determines which Group a grouped Parameter belongs to.

Grouped Parameters will be presented in a drop-down list.  If MutuallyExclusiveGroup is set to cFalse, more than one item can be selected from the drop-down list and added to a listbox.  All Parameters added to the listbox will have a True value, all those not in the listbox will have a False value.  If MutuallyExclusiveGroup is set to cTrue, then only the Parameter selected in the drop-down list will have a True value, and all other Boolean Parameters in that Group will have a False value.


MutuallyExclusiveGroup property - See also
Related

GroupNum

PartOfGroup

ParamFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


MutuallyExclusiveGroup property - Example
Example

This example retrieves the ParamFields values from the Report, and sets the first ParamField to allow editing, and to disallow multiple values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Info.AllowEditing := cTrue;

Crpe1.ParamFields[0].Info.AllowMultipleValues := cFalse;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


PartOfGroup property

See also	Example

Applies to

Info

Declaration

property PartOfGroup: TCrBoolean;

Description

The PartOfGroup property determines if the Parameter Field is grouped with other Parameter Fields.  If it is, it will appear on the same tab of the Prompt Dialog as the other Parameters it is grouped with.

Notes on Grouping

Grouping of Parameters only applies to Boolean Parameter Fields.  With Grouping, multiple Boolean Parameter Fields can be treated as a Group, whereby they will all appear on the same tab of the Parameter Field prompt dialog.  The PartOfGroup property turns the grouping feature on or off for a Parameter Field.  The GroupNum property determines which Group a grouped Parameter belongs to.

Grouped Parameters will be presented in a drop-down list.  If MutuallyExclusiveGroup is set to cFalse, more than one item can be selected from the drop-down list and added to a listbox.  All Parameters added to the listbox will have a True value, all those not in the listbox will have a False value.  If MutuallyExclusiveGroup is set to cTrue, then only the Parameter selected in the drop-down list will have a True value, and all other Boolean Parameters in that Group will have a False value.


PartOfGroup property - See also
Related

GroupNum

MutuallyExclusiveGroup

ParamFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PartOfGroup property - Example
Example

This example retrieves the ParamFields values from the Report, and sets the first ParamField to allow editing, and to disallow multiple values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Info.AllowEditing := cTrue;

Crpe1.ParamFields[0].Info.AllowMultipleValues := cFalse;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


ValueType property

See also	Example

Applies to

Info

Declaration

property ValueType: TCrParamInfoValueType;

Type

TCrParamInfoValueType = (vtRanges, vtDiscrete);

Description

The ValueType property specifies whether the Parameter Field uses Discrete values or Ranges.  The difference between Discrete and Range values are illustrated below:

Discrete Values

String	: "CA"

Number	: 12

Currency	: 22.33

Date	: 1998,01,01

Boolean	: False

Range Values

String	: "CA" to "WA"

Number	: 12 to 24

Currency	: 22.33 to 33.33

Date	: Date(1998,01,01) to Date(1998,01,31)

Boolean	: Range Values not available for Boolean

Note

The AllowMultipleValues property determines whether there can be more than one value passed in a ParamField.  In the case of Discrete Values, this would mean an array of values, ie: ["CA", "AK", "WA"].  In the case of Range values, this would mean an array of ranges, ie: ["CA" to "IL", "PA" to "WA"].


ValueType property - See also
Related

ParamFields

Ranges

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ValueType property - Example
Example

This example retrieves the ParamFields values from the Report, and sets the first ParamField to allow editing, and to disallow multiple values:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Info.AllowEditing := cTrue;

Crpe1.ParamFields[0].Info.AllowMultipleValues := cFalse;

Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

Info

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Info object, and does not need to be called in code, unless you are using the CopyFrom method to store Info data to a temporary object:

var

  tempInfo : TCrpeParamFieldInfo;

begin

  tempInfo := TCrpeParamFieldInfo.Create;

  tempInfo.CopyFrom(Crpe1.ParamFields.Info);

end;


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method

See also	Example

Applies to

Info

Declaration

procedure CopyFrom(Source: TCrpeParamFieldInfo);

Description

The CopyFrom method copies the Info property values from another TCrpeParamFieldInfo object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Info property values to a temporary TCrpeParamFieldInfo object:

var

tempInfo : TCrpeParamFieldInfo;

begin

tempInfo := TCrpeParamFieldInfo.Create;

tempInfo.CopyFrom(Crpe1.Paramfields.Info);

{...later, when finished with the temp object...}

tempInfo.Free;

end;


Retrieve method

See also	Example

Applies to

Info

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Parameter Field Info information (for the current ParamFields item) from the Report and stores it in the Info object.  If Parameter Field Info was not found, the call returns False.

Note

This method is automatically called internally in the ParamFields.Retrieve method, and so will not normally be required in code.


Retrieve method - See also
Related

Send

ParamFields

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

In this code example, the first ParamField item is manually created using the Add method.  The Add method requires the Parameter Name (assumed as "Parameter1" in this example) and the Report Name (blank for the main Report).  Then the ParamField Info property values are retrieved:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Add('Parameter1', '');

Crpe1.ParamFields[0].Info.Retrieve;


Send method

See also	Example

Applies to

Info

Declaration

function Send: boolean;

Description

The Send method sends the Info values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called (provided that SendOnExecute is set to True), or when ParamFields.Send is called.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the ParamFields Info settings for the first ParamField are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically for each ParamField in the ParamFields.Send method which is in turn called by the Execute method:

Crpe1.ParamFields[0].Info.Send;


Clear method

See also	Example

Applies to

Info

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the Info object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the Info object of the current ParamField, and the current Report/Subreport specified in the Subreports object.  Therefore, to clear all the ParamField Info of all the ParamFields in all the Subreports, will require a looping procedure that goes through each Subreport and applies the Clear to each ParamField.


Clear method - See also
Related

Retrieve

ParamFields.Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the ParamField Info for the first ParamField in the main Report (assuming the default state of Subreports[0]):

Crpe1.ParamFields[0].Info.Clear;

Note

Using ParamFields.Clear instead, will clear all the Info for all the ParamFields at once


Ranges

See also	Properties & Methods	Example

Applies to

ParamFields

Declaration

property Ranges: TCrpeParamFieldRanges;

Type

TCrpeParamFieldRanges = class(TPersistent)

Description

Only available with SCR 7 and higher.  The Ranges object is an extension of ParamFields that adds range capability to the Parameter values that can be passed to a Report.  Ranges are different from regular Parameters in that they have a starting and ending value, instead of just a single value.

When a Report is designed, the Parameter field can be set up as having Discrete (single) values, or having Range (start and end) values.  This can be changed at runtime via the ParamField.Info.ValueType property.  The ValueType of a ParamField must be vtRanges in order for the Range object properties to have an effect.

Ranges are similar to "Current" values, in that there will be no range values in a Report unless it has been run already, or it has Saved Data.  Therefore, passing values via the Ranges object is normally not done unless you want to bypass the Crystal Reports Parameter Field dialog for that particular Parameter.  If the Parameter dialog is to appear, then possible choices for the start and end range values should be passed via the ParamField.DefaultValues property.

•	The Retrieve method will fetch the Ranges values from the Report and fill the Ranges object with corresponding items.

•	The Count method returns the number of Ranges items currently contained in the Ranges object.

•	The Number property specifies Range Number of the item that the Ranges object is currently pointing to.

•	The Item and ItemIndex properties can be used to navigate through the Ranges object.

•	The RangeStart property determines the starting value of the Range.

•	The RangeEnd property determines the ending value of the Range.

•	The RangeBounds property determines how Crystal Reports will treat the values that match the range; that is, whether the values that fall within the Range include the RangeStart and RangeEnd values, or exclude them.

•	The Clear method removes all items from the Ranges object.

•	The Add and Delete methods provide a manual alternative to Retrieve/Clear for adding and deleting items from  the Ranges object.


Ranges - See also
Related

ParamFields

Info

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Ranges - Properties & Methods
Ranges:

Properties & Methods

Ranges	TCrpe Component

Properties

RangeBounds

RangeEnd

RangeStart

Key

Number

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

Retrieve

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


Ranges - Example
Example

The following example illustrates the use of the Ranges object:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Parameters}

Crpe1.ParamFields.Retrieve;

{ByPass the Parameter Prompt Dialog}

Crpe1.ParamFields[0].ShowDialog := False;

{Make sure ValueType is set to Ranges}

Crpe1.ParamFields[0].Info.ValueType := vtRanges;

{Clear Ranges, just to be safe}

Crpe1.ParamFields[0].Ranges.Clear;

{Add a Range}

Crpe1.ParamFields[0].Ranges.Add(0);

Crpe1.ParamFields[0].Ranges[0].RangeStart := 'CA';

Crpe1.ParamFields[0].Ranges[0].RangeEnd := 'WA';

Crpe1.ParamFields[0].Ranges[0].RangeBounds := IncludeStartAndEnd;

Crpe1.Output := toWindow;

Crpe1.Execute;


Item property

See also	Example

Applies to

Ranges

Declaration

property Item[nIndex: integer]: TCrpeParamFieldRanges;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the Ranges object, allowing the object to be treated like an array.

•	Item is a default property, it does not need to be specified when using the subscript:  Ranges[2] is the same as Ranges.Item[2].

•	Item returns a reference to the Ranges object, so the Ranges properties can be used right after the subscript: Ranges[2].RangeBounds := IncludeStartAndEnd;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{Set Ranges to the 1st Range}

Crpe1.ParamFields[0].Ranges.Item[0];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{Set Ranges to the 1st Range}

Crpe1.ParamFields[0].Ranges[0];


ItemIndex property

See also	Example

Applies to

Ranges

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current Ranges item number, or set the Ranges object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (Expressions[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Expressions.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the Ranges object is pointing to the first Range:

if Crpe1.ParamFields[0].Ranges.ItemIndex <> 0 then

  Crpe1.ParamFields[0].Ranges[0];


Number property

See also	Example

Applies to

Ranges

Declaration

property Number: TCrRangeNumber;

Type

TCrRangeNumber = integer;

Description

The Number property specifies the Range Number of the item that the Ranges object is currently pointing to.


Number property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

This example retrieves the ParamFields values from the Report (the Range values are retrieved with the ParamFields), and uses the Number property to set the first Range:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the ParamFields from the Report}

Crpe1.ParamFields.Retrieve;

if Crpe1.ParamFields[0].Ranges.Count > 0 then

begin

  {Set the ParamFields Ranges object to the first Range}

  Crpe1.ParamFields[0].Ranges.Number := 0;

  {Assign the values for the first Range}

  Crpe1.ParamFields[0].Ranges.RangeStart := 'CA';

  Crpe1.ParamFields[0].Ranges.RangeEnd := 'WA';

  Crpe1.ParamFields[0].Ranges.RangeBounds := IncludeStartAndEnd;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


RangeBounds property

See also	Example

Applies to

Ranges

Declaration

property RangeBounds: TCrRangeBounds;

Type

TCrRangeBounds = (IncludeStartAndEnd, IncludeStartOnly, IncludeEndOnly, ExcludeStartAndEnd);

Description

The RangeBounds property determines whether the limit of values that can be entered into the Parameter include the RangeStart and RangeEnd values, or exclude them.  When using the Add method, the default setting for RangeBounds is IncludeStartAndEnd.


RangeBounds property - See also
Related

RangeStart

RangeEnd

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


RangeBounds property - Example
Example

The following example illustrates the use of the Ranges object:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Parameters}

Crpe1.ParamFields.Retrieve;

{ByPass the Parameter Prompt Dialog}

Crpe1.ParamFields[0].ShowDialog := False;

{Make sure ValueType is set to Ranges}

Crpe1.ParamFields[0].Info.ValueType := vtRanges;

{Clear Ranges, just to be safe}

Crpe1.ParamFields[0].Ranges.Clear;

{Add a Range}

Crpe1.ParamFields[0].Ranges.Add(0);

Crpe1.ParamFields[0].Ranges[0].RangeStart := 'CA';

Crpe1.ParamFields[0].Ranges[0].RangeEnd := 'WA';

Crpe1.ParamFields[0].Ranges[0].RangeBounds := IncludeStartAndEnd;

Crpe1.Output := toWindow;

Crpe1.Execute;


RangeEnd property

See also	Example

Applies to

Ranges

Declaration

property RangeEnd: string;

Description

The RangeEnd property determines the starting value of the Range.  Depending on the setting of the RangeBounds property, the actual Range (as Crystal Reports sees it) will either include the RangeEnd value, or exclude it.


RangeEnd property - See also
Related

RangeStart

RangeBounds

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


RangeEnd property - Example
Example

The following example illustrates the use of the Ranges object:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Parameters}

Crpe1.ParamFields.Retrieve;

{ByPass the Parameter Prompt Dialog}

Crpe1.ParamFields[0].ShowDialog := False;

{Make sure ValueType is set to Ranges}

Crpe1.ParamFields[0].Info.ValueType := vtRanges;

{Clear Ranges, just to be safe}

Crpe1.ParamFields[0].Ranges.Clear;

{Add a Range}

Crpe1.ParamFields[0].Ranges.Add(0);

Crpe1.ParamFields[0].Ranges[0].RangeStart := 'CA';

Crpe1.ParamFields[0].Ranges[0].RangeEnd := 'WA';

Crpe1.ParamFields[0].Ranges[0].RangeBounds := IncludeStartAndEnd;

Crpe1.Output := toWindow;

Crpe1.Execute;


RangeStart property

See also	Example

Applies to

Ranges

Declaration

property RangeStart: string;

Description

The RangeStart property determines the starting value of the Range.  Depending on the setting of the RangeBounds property, the actual Range (as Crystal Reports sees it) will either include the RangeStart value, or exclude it.


RangeStart property - See also
Related

RangeEnd

RangeBounds

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


RangeStart property - Example
Example

The following example illustrates the use of the Ranges object:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the Parameters}

Crpe1.ParamFields.Retrieve;

{ByPass the Parameter Prompt Dialog}

Crpe1.ParamFields[0].ShowDialog := False;

{Make sure ValueType is set to Ranges}

Crpe1.ParamFields[0].Info.ValueType := vtRanges;

{Clear Ranges, just to be safe}

Crpe1.ParamFields[0].Ranges.Clear;

{Add a Range}

Crpe1.ParamFields[0].Ranges.Add(0);

Crpe1.ParamFields[0].Ranges[0].RangeStart := 'CA';

Crpe1.ParamFields[0].Ranges[0].RangeEnd := 'WA';

Crpe1.ParamFields[0].Ranges[0].RangeBounds := IncludeStartAndEnd;

Crpe1.Output := toWindow;

Crpe1.Execute;


Create method

See also

Applies to

Ranges

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Ranges object, and does not need to be called in code, unless you are using the CopyFrom method to store Ranges data to a temporary object:

var

  tempRanges : TCrpeParamFieldRanges;

begin

  tempRanges := TCrpeParamFieldRanges.Create;

  tempRanges.CopyFrom(Crpe1.ParamFields.Ranges);

end;


Create method - See also
Related

CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method

See also	Example

Applies to

Ranges

Declaration

procedure CopyFrom(Source: TCrpeParamFieldRanges);

Description

The CopyFrom method copies the Ranges property values from another TCrpeParamFieldRanges object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Ranges property values to a temporary TCrpeParamFieldRanges object:

var

tempRanges : TCrpeParamFieldRanges;

begin

tempRanges := TCrpeParamFieldRanges.Create;

tempRanges.CopyFrom(Crpe1.ParamFields.Ranges);

{...later, when finished with the temp object...}

tempRanges.Free;

end;


Count method

See also	Example

Applies to

Ranges

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the Ranges object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

if Crpe1.ParamFields[0].Ranges.Count > 0 then

begin

for cnt := 0 to (Crpe1.ParamFields[0].Ranges.Count - 1) do

  Crpe1.ParamFields[0].Ranges[cnt].RangeBounds := IncludeStartAndEnd;

end;

end;


Retrieve method

See also	Example

Applies to

Ranges

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Parameter Field Ranges information (for the current ParamFields item) from the Report and stores it in the Ranges object.  If Ranges information was not found, the call returns False.  If there are no Ranges items in the Report, they can be added using the manual Add method.


Retrieve method - See also
Related

Add

Clear

Send

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

In this code example, the first ParamField item is manually created using the Add method.  The Add method requires the Parameter Name (assumed as "Parameter1" in this example) and the Report Name (blank for the main Report).  Then the ParamField Ranges property values are retrieved:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Add('Parameter1', '');

Crpe1.ParamFields[0].Ranges.Retrieve;


Send method

See also	Example

Applies to

Ranges

Declaration

function Send: boolean;

Description

The Send method sends the Ranges values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called (provided that SendOnExecute is set to True), or when ParamFields.Send is called.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine.  If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method.  This feature is mainly provided for debugging purposes.


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the ParamFields Ranges settings for the first ParamField are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically for each ParamField in the ParamFields.Send method which is in turn called by the Execute method:

Crpe1.ParamFields[0].Ranges.Send;


Add method

See also	Example

Applies to

Ranges

Declaration

function Add(RangeNumber: TCrRangeNumber): integer;

Type

TCrRangeNumber = integer;

Description

The Add method adds an item to the Ranges object and sets the internal index to that item.  It requires a Range number (zero based) as a parameter.

The steps to using the Add method with Ranges are:

1. Add an item to the Ranges object (you must specify the Range Number).

2. Fill the item's properties (RangeStart, RangeEnd, and RangeBounds) with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

If the Parameter is set up to expect a single Range (ParamFields.Info.AllowMultipleValues is set to cFalse), then only one Range item will be required.  If the Parameter is set up to expect an array of Ranges (ParamFields.Info.AllowMultipleValues is set to cTrue), then as many Range items as desired can be added to the Ranges object.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the Ranges object:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{Specify Range Number}

Crpe1.ParamFields[0].Ranges.Add(0);

Crpe1.ParamFields[0].Ranges[0].RangeStart := 'CA';

Crpe1.ParamFields[0].Ranges[0].RangeEnd := 'WA';

Crpe1.ParamFields[0].Ranges[0].RangeBounds := IncludeStartAndEnd;

Crpe1.Output := toWindow;

Crpe1.Execute;


Clear method

See also	Example

Applies to

Ranges

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the ParamField Ranges object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, or if the Paramfield.Clear method is called, but may be called in code as desired.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the ParamField Ranges for the first ParamField in the main Report (assuming the default state of Subreports[0]):

Crpe1.ParamFields[0].Ranges.Clear;

Note

Using ParamFields.Clear instead, will clear all the Ranges for all the ParamFields at once


Delete method

See also	Example

Applies to

Ranges

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the Ranges object.  The "nIndex" parameter represents the order of the item in the Ranges object, which should not be confused with the Range Number value.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the Ranges object:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ParamFields.Retrieve;

{Specify Range Number}

Crpe1.ParamFields[0].Ranges.Add(0);

Crpe1.ParamFields[0].Ranges[0].RangeStart := 'CA';

Crpe1.ParamFields[0].Ranges[0].RangeEnd := 'WA';

Crpe1.ParamFields[0].Ranges[0].RangeBounds := IncludeStartAndEnd;

Crpe1.Output := toWindow;

Crpe1.Execute;

{Specify the item number}

Crpe1.ParamFields[0].Ranges.Delete(0);


Destroy method

See also

Applies to

Ranges

Declaration

destructor Destroy;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
Related

Create

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GraphAxis

See also	Properties & Methods	Example

Declaration

property GraphAxis: TCrpeGraphAxis;

Type

TCrpeGraphAxis = class(TPersistent)

Description

Only available with SCR 7 and higher.  The GraphAxis class controls the Grid Lines, Max/Min Data Values, Number Format, and Divisions of the axes of a Graph.

•	The Number property specifies the Graph Number, and can be used as a lookup value to point the GraphAxis object to a specific GraphAxis item.  See How Graphs are Numbered for more information on the numbering scheme.

•	The Section property specifies the section that the Graph is located in, and uses the "short" section naming convention used in the Crystal Reports Designer.  See "About Section Names" for more information.

•	The Retrieve method can be used to fill the GraphAxis object with information from the Report.

•	The Count method will indicate how many GraphAxis items are currently in the GraphAxis object.

•	The Item and ItemIndex properties can be used to navigate through the GraphAxis items in the GraphAxis object.

•	The GridLineX, GridLineY, GridLineY2, and GridLineZ properties specify whether gridlines will appear on the Graph, and how frequently.

•	The DataValuesY, DataValuesY2, and DataValuesZ  properties  specify whether summary numbers will appear at the top of each Bar (if a bar graph is used), or off each Pie Slice (if a pie graph is used).

•	The MinY, MaxY, MinY2, MaxY2, MinZ, and MaxZ properties specify the minimum and maximum values that will control the range of data that is displayed on the Graph.

•	The NumberFormatY, NumberFormatY2, and NumberFormatZ   properties specify the prefix and decimal format of the numbers used on the Graph axes.

•	The DivisionTypeY, DivisionTypeY2, DivisionTypeZ properties specify  whether the value axis divisions (the y axis on a vertical bar graph) of the Graph are placed automatically, or whether the frequency of their spacing can be set manually.

•	The DivisionsY, DivisionsY2, and DivisionsZ properties specify the frequency of the value axis divisions when DivisionType (see above) is set to Manual.


GraphAxis - See also
Related

GraphOptionInfo

GraphType

GraphText

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GraphAxis - Properties & Methods
GraphAxis:

Properties & Methods

GraphAxis	TCrpe Component

Properties

DataValuesY

DataValuesY2

DataValuesZ

DivisionsY

DivisionsY2

DivisionsZ

DivisionTypeY

DivisionTypeY2

DivisionTypeZ

GridLineX

GridLineY

GridLineY2

GridLineZ

MinY

MaxY

MinY2

MaxY2

MinZ

MaxZ

NumberFormatY

NumberFormatY2

NumberFormatZ

Section

SectionAsCode

SectionGraphNum

Key

Number

Navigation

Item

ItemIndex

Methods

Clear

CopyFrom

Count

IndexOf

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


GraphAxis - Example
Example

This code changes various GraphAxis properties for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].GridLineX := gglMajorAndMinor;

Crpe1.GraphAxis[0].DataValuesY := gdvManual;

Crpe1.GraphAxis[0].MinY := 0;

Crpe1.GraphAxis[0].MaxY := 15000;

Crpe1.GraphAxis[0].NumberFormatY := gnfCurrencyTwoDecimal;

Crpe1.GraphAxis[0].DivisionTypeY := gdvManual;

Crpe1.GraphAxis[0].DivisionsY := 4;

Crpe1.Output := toWindow;

Crpe1.Execute;


Number property

See also	Example

Applies to

GraphAxis

Declaration

property Number: TCrGraphAxisNumber;

Type

TCrGraphAxisNumber = integer;

Description

The Number property specifies the Graph Number.

•	If the Retrieve method is used to fill the GraphAxis object with infomation from the Report, each GraphAxis item will have a unique Graph Number assigned by the VCL.

•	If the manual Add method is used instead, a Graph number will have to be specifed which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered).

The primary use of the Number property is as a look-up to point the GraphAxis object to the item with the Graph number specified.  The default array property, Item, however, provides an easier way to navigate through the object.


Number property - See also
Related

Item

ItemIndex

SectionGraphNum

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

This example retrieves the GraphAxis values from the Report, and uses the Number property to access the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the GraphAxis from the Report}

Crpe1.GraphAxis.Retrieve;

{Set the GraphAxis object to Graph Number 1}

Crpe1.GraphAxis.Number := 1;

{Assign the values for Graph Number 1}

Crpe1.GraphAxis.DataValuesY := gdvManual;

Crpe1.GraphAxis.MinY := 0;

Crpe1.GraphAxis.MaxY := 15000;

Crpe1.Output := toWindow;

Crpe1.Execute;


Section property

See also	Example

Applies to

GraphAxis

Declaration

property Section: string;

Description

The Section property contains the Section name of the item that the GraphAxis object is currently pointed to.  It indicates in which Section of the Report that the Graph is located.

Note that you cannot move a Graph from one Section to another by changing this property.  It should primarily be used as a read-only property after the GraphAxis information has been retrieved with the Retrieve method.  If the manual Add method is used to add items to the GraphAxis object, then Section will have to be assigned the correct  value in code.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections.  Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.


Section property - See also
Related

About Section Names

IndexOf

SectionAsCode

SectionType

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


Section property - Example
Example

In the following example, the Section property is used to apply changes only to Graphs which exist in a given Report Section (Page Header in this case):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

for cnt := 0 to (Crpe1.GraphAxis.Count - 1) do

begin

  if Crpe1.GraphAxis[cnt].Section = 'PH' then

    Crpe1.GraphAxis[0].NumberFormatY := gnfCurrencyTwoDecimal;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


GridLineX property

See also	Example

Applies to

GraphAxis

Declaration

property GridLineX: TCrGraphGridLines;

Type

TCrGraphGridLines = (gglDefault, gglNone, gglMinor, gglMajor, gglMajorAndMinor);

Description

The GridLineX property specifies whether X-Axis gridlines will appear on the Graph, and how frequently.

Note

Minor GridLines are not visible at this time because their default drawing color is white.  You will have to customize the Graph in Crystal Reports Designer to get Minor GridLines to show.


GridLineX property - See also
Related

GridLineY

GridLineY2

GridLineZ

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


GridLineX property - Example
Example

This code changes the X-Axis (Group) GridLines for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

{Show Major and Minor Gridlines}

Crpe1.GraphAxis[0].GridLineX := gglMajorAndMinor;

Crpe1.Output := toWindow;

Crpe1.Execute;


GridLineY property

See also	Example

Applies to

GraphAxis

Declaration

property GridLineY: TCrGraphGridLines;

Type

TCrGraphGridLines = (gglDefault, gglNone, gglMinor, gglMajor, gglMajorAndMinor);

Description

The GridLineY property specifies whether Y-Axis gridlines will appear on the Graph, and how frequently.

Note

Minor GridLines are not visible at this time because their default drawing color is white.  You will have to customize the Graph in Crystal Reports Designer to get Minor GridLines to show.


GridLineY property - See also
Related

GridLineX

GridLineY2

GridLineZ

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


GridLineY property - Example
Example

This code changes the Y-Axis (Data) GridLines for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

{Show Major and Minor Gridlines}

Crpe1.GraphAxis[0].GridLineY := gglMajorAndMinor;

Crpe1.Output := toWindow;

Crpe1.Execute;


GridLineY2 property

See also	Example

Applies to

GraphAxis

Declaration

property GridLineY2: TCrGraphGridLines;

Type

TCrGraphGridLines = (gglDefault, gglNone, gglMinor, gglMajor, gglMajorAndMinor);

Description

The GridLineY2 property specifies whether the second Y-Axis gridlines will appear on the Graph, and how frequently.

Notes

•	Minor GridLines are not visible at this time because their default drawing color is white.  You will have to customize the Graph in Crystal Reports Designer to get Minor GridLines to show.

•	The Y2 axis is only available with certain graph types and under certain graphing conditions (I know that's vague, but I don't have any better information!).


GridLineY2 property - See also
Related

GridLineX

GridLineY

GridLineZ

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


GridLineY2 property - Example
Example

This code changes the Y2-Axis (Second Data Axis) GridLines for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

{Show Major and Minor Gridlines}

Crpe1.GraphAxis[0].GridLineY2 := gglMajorAndMinor;

Crpe1.Output := toWindow;

Crpe1.Execute;


GridLineZ property

See also	Example

Applies to

GraphAxis

Declaration

property GridLineZ: TCrGraphGridLines;

Type

TCrGraphGridLines = (gglDefault, gglNone, gglMinor, gglMajor, gglMajorAndMinor);

Description

The GridLineZ property specifies whether Z-Axis gridlines will appear on the Graph, and how frequently.  The Z-Axis is only available on 3D Graphs.

Note

Minor GridLines are not visible at this time because their default drawing color is white.  You will have to customize the Graph in Crystal Reports Designer to get Minor GridLines to show.


GridLineZ property - See also
Related

GridLineX

GridLineY

GridLineY2

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


GridLineZ property - Example
Example

This code changes the Z-Axis GridLines for the first Graph in the Report (Z-Axis is only available on 3D graphs):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

{Show Major and Minor Gridlines}

Crpe1.GraphAxis[0].GridLineZ := gglMajorAndMinor;

Crpe1.Output := toWindow;

Crpe1.Execute;


DataValuesY property

See also	Example

Applies to

GraphAxis

Declaration

property DataValuesY: TCrGraphDVType;

Type

TCrGraphDVType = (gdvDefault, gdvAutomatic, gdvManual);

Description

The DataValuesY property determines how the Y-Axis scale will be calculated.  If it is set to gdvManual then the MinY, MaxY, and NumberFormatY properties determine the format and range of the Y-Axis scale.


DataValuesY property - See also
Related

DataValuesY2

DataValuesZ

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


DataValuesY property - Example
Example

This code changes the DataValuesY property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesY := gdvManual;

Crpe1.GraphAxis[0].MinY := 0;

Crpe1.GraphAxis[0].MaxY := 15000;

Crpe1.GraphAxis[0].NumberFormatY := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


DataValuesY2 property

See also	Example

Applies to

GraphAxis

Declaration

property DataValuesY2: TCrGraphDVType;

Type

TCrGraphDVType = (gdvDefault, gdvAutomatic, gdvManual);

Description

The DataValuesY2 property determines how the Y2-Axis scale will be calculated.  If it is set to gdvManual then the MinY2, MaxY2, and NumberFormatY2 properties determine the format and range of the Y2-Axis scale.

Notes

The Y2 axis is only available with certain graph types and under certain graphing conditions (I know that's vague, but I don't have any better information!).


DataValuesY2 property - See also
Related

DataValuesY

DataValuesZ

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


DataValuesY2 property - Example
Example

This code changes the DataValuesY2 property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesY2 := gdvManual;

Crpe1.GraphAxis[0].MinY2 := 0;

Crpe1.GraphAxis[0].MaxY2 := 15000;

Crpe1.GraphAxis[0].NumberFormatY2 := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


DataValuesZ property

See also	Example

Applies to

GraphAxis

Declaration

property DataValuesZ: TCrGraphDVType;

Type

TCrGraphDVType = (gdvDefault, gdvAutomatic, gdvManual);

Description

The DataValuesZ property determines how the Z-Axis scale will be calculated.  If it is set to gdvManual then the MinZ, MaxZ, and NumberFormatZ properties determine the format and range of the Z-Axis scale.

Note

The Z axis is only available with 3D Graphs.


DataValuesZ property - See also
Related

DataValuesY

DataValuesY2

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


DataValuesZ property - Example
Example

This code changes the DataValuesZ property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesZ := gdvManual;

Crpe1.GraphAxis[0].MinZ := 0;

Crpe1.GraphAxis[0].MaxZ := 15000;

Crpe1.GraphAxis[0].NumberFormatZ := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


MinY property

See also	Example

Applies to

GraphAxis

Declaration

property MinY: double;

Description

The MinY property determines the starting point of the Y-Axis scale.  The DataValuesY property must be set to gdvManual in order for the MinY setting to have an effect on the Graph.


MinY property - See also
Related

DataValuesY

MaxY

NumberFormatY

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


MinY property - Example
Example

This code changes the MinY property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesY := gdvManual;

Crpe1.GraphAxis[0].MinY := 0;

Crpe1.GraphAxis[0].MaxY := 15000;

Crpe1.GraphAxis[0].NumberFormatY := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


MaxY property

See also	Example

Applies to

GraphAxis

Declaration

property MaxY: double;

Description

The MaxY property determines the end point of the Y-Axis scale.  The DataValuesY property must be set to gdvManual in order for the MaxY setting to have an effect on the Graph.


MaxY property - See also
Related

DataValuesY

MinY

NumberFormatY

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


MaxY property - Example
Example

This code changes the MaxY property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesY := gdvManual;

Crpe1.GraphAxis[0].MinY := 0;

Crpe1.GraphAxis[0].MaxY := 15000;

Crpe1.GraphAxis[0].NumberFormatY := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


MinY2 property

See also	Example

Applies to

GraphAxis

Declaration

property MinY2: double;

Description

The MinY2 property determines the starting point of the Y2-Axis scale.  The DataValuesY2 property must be set to gdvManual in order for the MinY2 setting to have an effect on the Graph.

Notes

The Y2 axis is only available with certain graph types and under certain graphing conditions (I know that's vague, but I don't have any better information!).


MinY2 property - See also
Related

DataValuesY2

MaxY2

NumberFormatY2

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


MinY2 property - Example
Example

This code changes the MinY2 property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesY2 := gdvManual;

Crpe1.GraphAxis[0].MinY2 := 0;

Crpe1.GraphAxis[0].MaxY2 := 15000;

Crpe1.GraphAxis[0].NumberFormatY2 := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


MaxY2 property

See also	Example

Applies to

GraphAxis

Declaration

property MaxY2: double;

Description

The MaxY2 property determines the ending point of the Y2-Axis scale.  The DataValuesY2 property must be set to gdvManual in order for the MaxY2 setting to have an effect on the Graph.

Notes

The Y2 axis is only available with certain graph types and under certain graphing conditions (I know that's vague, but I don't have any better information!).


MaxY2 property - See also
Related

DataValuesY2

MinY2

NumberFormatY2

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


MaxY2 property - Example
Example

This code changes the MaxY2 property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesY2 := gdvManual;

Crpe1.GraphAxis[0].MinY2 := 0;

Crpe1.GraphAxis[0].MaxY2 := 15000;

Crpe1.GraphAxis[0].NumberFormatY2 := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


MinZ property

See also	Example

Applies to

GraphAxis

Declaration

property MinZ: double;

Description

The MinZ property determines the starting point of the Z-Axis scale.  The DataValuesZ property must be set to gdvManual in order for the MinZ setting to have an effect on the Graph.

Note

The Z-Axis is only available with 3D Graphs.


MinZ property - See also
Related

DataValuesZ

MaxZ

NumberFormatZ

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


MinZ property - Example
Example

This code changes the MinZ property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesZ := gdvManual;

Crpe1.GraphAxis[0].MinZ := 0;

Crpe1.GraphAxis[0].MaxZ := 15000;

Crpe1.GraphAxis[0].NumberFormatZ := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


MaxZ property

See also	Example

Applies to

GraphAxis

Declaration

property MaxZ: double;

Description

The MaxZ property determines the ending point of the Z-Axis scale.  The DataValuesZ property must be set to gdvManual in order for the MaxZ setting to have an effect on the Graph.

Note

The Z axis is only available with 3D Graphs.


MaxZ property - See also
Related

DataValuesZ

MinZ

NumberFormatZ

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


MaxZ property - Example
Example

This code changes the MaxZ property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesZ := gdvManual;

Crpe1.GraphAxis[0].MinZ := 0;

Crpe1.GraphAxis[0].MaxZ := 15000;

Crpe1.GraphAxis[0].NumberFormatZ := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


NumberFormatY property

See also	Example

Applies to

GraphAxis

Declaration

property NumberFormatY: TCrGraphNumberFormat;

Type

TCrGraphNumberFormat = (gnfDefault, gnfNoDecimal, gnfOneDecimal, gnfTwoDecimal, gnfCurrencyNoDecimal, gnfCurrencyTwoDecimal, gnfPercentNoDecimal, gnfPercentOneDecimal, gnfPercentTwoDecimal);

Description

The NumberFormatY property determines the formatting of the numbers that mark the Y-Axis scale.


NumberFormatY property - See also
Related

DataValuesY

MinY

MaxY

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


NumberFormatY property - Example
Example

This code changes the NumberFormatY property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesY := gdvManual;

Crpe1.GraphAxis[0].MinY := 0;

Crpe1.GraphAxis[0].MaxY := 15000;

Crpe1.GraphAxis[0].NumberFormatY := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


NumberFormatY2 property

See also	Example

Applies to

GraphAxis

Declaration

property NumberFormatY2: TCrGraphNumberFormat;

Type

TCrGraphNumberFormat = (gnfDefault, gnfNoDecimal, gnfOneDecimal, gnfTwoDecimal, gnfCurrencyNoDecimal, gnfCurrencyTwoDecimal, gnfPercentNoDecimal, gnfPercentOneDecimal, gnfPercentTwoDecimal);

Description

The NumberFormatY2 property determines the formatting of the numbers that mark the Y2-Axis scale.

Notes

The Y2 axis is only available with certain graph types and under certain graphing conditions (I know that's vague, but I don't have any better information!).


NumberFormatY2 property - See also
Related

DataValuesY2

MinY2

MaxY2

NumberFormatY2

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


NumberFormatY2 property - Example
Example

This code changes the NumberFormatY2 property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesY2 := gdvManual;

Crpe1.GraphAxis[0].MinY2 := 0;

Crpe1.GraphAxis[0].MaxY2 := 15000;

Crpe1.GraphAxis[0].NumberFormatY2 := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


NumberFormatZ property

See also	Example

Applies to

GraphAxis

Declaration

property NumberFormatZ: TCrGraphNumberFormat;

Type

TCrGraphNumberFormat = (gnfDefault, gnfNoDecimal, gnfOneDecimal, gnfTwoDecimal, gnfCurrencyNoDecimal, gnfCurrencyTwoDecimal, gnfPercentNoDecimal, gnfPercentOneDecimal, gnfPercentTwoDecimal);

Description

The NumberFormatZ property determines the formatting of the numbers that mark the Z-Axis scale.

Note

The Z axis is only available with 3D Graphs.


NumberFormatZ property - See also
Related

DataValuesZ

MinZ

MaxZ

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


NumberFormatZ property - Example
Example

This code changes the NumberFormatZ property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DataValuesZ := gdvManual;

Crpe1.GraphAxis[0].MinZ := 0;

Crpe1.GraphAxis[0].MaxZ := 15000;

Crpe1.GraphAxis[0].NumberFormatZ := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


DivisionTypeY property

See also	Example

Applies to

GraphAxis

Declaration

property DivisionTypeY: TCrGraphDVType;

Type

TCrGraphDVType = (gdvDefault, gdvAutomatic, gdvManual);

Description

The DivisionTypeY property determines whether the Y-Axis divisions will be calculated automatically, or whether they will be manually specified.  If DivisionTypeY is set to gdvManual, the DivisionsY property controls the number of divisions that the Y-Axis will be divided into.


DivisionTypeY property - See also
Related

DivisionsY

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


DivisionTypeY property - Example
Example

This code changes the DivisionTypeY property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DivisionTypeY := gdvManual;

Crpe1.GraphAxis[0].DivisionsY := 4;

Crpe1.Output := toWindow;

Crpe1.Execute;


DivisionTypeY2 property

See also	Example

Applies to

GraphAxis

Declaration

property DivisionTypeY2: TCrGraphDVType;

Type

TCrGraphDVType = (gdvDefault, gdvAutomatic, gdvManual);

Description

The DivisionTypeY2 property determines whether the Y2-Axis divisions will be calculated automatically, or whether they will be manually specified.  If DivisionTypeY2 is set to gdvManual, the DivisionsY2 property controls the number of divisions that the Y2-Axis will be divided into.


DivisionTypeY2 property - See also
Related

DivisionsY2

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


DivisionTypeY2 property - Example
Example

This code changes the DivisionTypeY2 property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DivisionTypeY2 := gdvManual;

Crpe1.GraphAxis[0].DivisionsY2 := 4;

Crpe1.Output := toWindow;

Crpe1.Execute;


DivisionTypeZ property

See also	Example

Applies to

GraphAxis

Declaration

property DivisionTypeZ: TCrGraphDVType;

Type

TCrGraphDVType = (gdvDefault, gdvAutomatic, gdvManual);

Description

The DivisionTypeZ property determines whether the Z-Axis divisions will be calculated automatically, or whether they will be manually specified.  If DivisionTypeZ is set to gdvManual, the DivisionsZ property controls the number of divisions that the Z-Axis will be divided into.

Note

The Z axis is only available with 3D Graphs.


DivisionTypeZ property - See also
Related

DivisionsZ

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


DivisionTypeZ property - Example
Example

This code changes the DivisionTypeZ property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DivisionTypeZ := gdvManual;

Crpe1.GraphAxis[0].DivisionsZ := 4;

Crpe1.Output := toWindow;

Crpe1.Execute;


DivisionsY property

See also	Example

Applies to

GraphAxis

Declaration

property DivisionsY: LongInt;

Description

The DivisionsY property determines the number of divisions on the Y-Axis of the Graph.  Note that DivisionTypeY must be set to gdvManual for the DivisionsY settings to have effect.


DivisionsY property - See also
Related

DivisionTypeY

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


DivisionsY property - Example
Example

This code changes the DivisionsY property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DivisionTypeY := gdvManual;

Crpe1.GraphAxis[0].DivisionsY := 4;

Crpe1.Output := toWindow;

Crpe1.Execute;


DivisionsY2 property

See also	Example

Applies to

GraphAxis

Declaration

property DivisionsY2: LongInt;

Description

The DivisionsY2 property determines the number of divisions on the Y2-Axis of the Graph.  Note that DivisionTypeY2 must be set to gdvManual for the DivisionsY2 settings to have effect.


DivisionsY2 property - See also
Related

DivisionTypeY2

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


DivisionsY2 property - Example
Example

This code changes the DivisionsY2 property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DivisionTypeY2 := gdvManual;

Crpe1.GraphAxis[0].DivisionsY2 := 4;

Crpe1.Output := toWindow;

Crpe1.Execute;


DivisionsZ property

See also	Example

Applies to

GraphAxis

Declaration

property DivisionsZ: LongInt;

Description

The DivisionsZ property determines the number of divisions on the Z-Axis of the Graph.  Note that DivisionTypeZ must be set to gdvManual for the DivisionsZ settings to have effect.

Note

The Z axis is only available with 3D Graphs.


DivisionsZ property - See also
Related

DivisionTypeZ

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


DivisionsZ property - Example
Example

This code changes the DivisionsZ property for the first Graph in the Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

Crpe1.GraphAxis[0].DivisionTypeZ := gdvManual;

Crpe1.GraphAxis[0].DivisionsZ := 4;

Crpe1.Output := toWindow;

Crpe1.Execute;


SectionGraphNum property

See also	Example

Applies to

GraphAxis

Declaration

property SectionGraphNum: smallint;

Description

The SectionGraphNum property specifies the Graph Number as numbered from left to right within the Section it resides.  This is the numbering scheme used by the Print Engine, however the Crystal VCL also uses its own numbering scheme which is reflected in the Number property (so that each Graph has a unique number).

•	If the Retrieve method is used to fill the GraphAxis object with infomation from the Report, the SectionGraphNum values are retrieved automatically.

•	If the manual Add method is used instead, a SectionGraphNum value will have to be specifed which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered).

This property is mainly provided for those who wish to use the manual Add method.


SectionGraphNum property - See also
Related

Item

ItemIndex

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionGraphNum property - Example
Example

This example manually adds an item to the GraphAxis class and sets the SectionGraphNum accordingly:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

nItem := Crpe1.GraphAxis.Add(0);

Crpe1.GraphAxis[nItem].SectionGraphNum := 0;

{Show Major and Minor Gridlines}

Crpe1.GraphAxis[nItem].GridLineX := gglMajorAndMinor;

Crpe1.Execute;

end;


Item property

See also	Example

Applies to

GraphAxis

Declaration

property Item[const nIndex: integer]: TCrpeGraphAxis;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the GraphAxis object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  GraphAxis[2] is the same as GraphAxis.Item[2].

•	Item returns a reference to the GraphAxis object, so the GraphAxis properties can be used right after the subscript: GraphAxis[2].Number := 1;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

{Set GraphAxis to first item}

Crpe1.GraphAxis.Item[0];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

{Set GraphAxis to first item}

Crpe1.GraphAxis[0];


ItemIndex property

See also	Example

Applies to

GraphAxis

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GraphAxis item number, or set the GraphAxis object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (GraphAxis[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like GraphAxis.Number, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the GraphAxis object is pointing to the first Graph:

if Crpe1.GraphAxis.ItemIndex <> 0 then

  Crpe1.GraphAxis[0];


SectionAsCode property

See also	Example

Applies to

GraphAxis

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

Section

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The SectionAsCode property can be used to apply formula-based formatting to specific sections based on mathematical calculations or comparisons.  The following code checks each Graph to see if it is in a "b" section, such as RHb, PHb, Db, etc, and if it is, the major and minor Gridlines are turned on (which doesn't make a whole lot of sense, but serves to illustrate how to use these calls!):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

for cnt := 0 to (Crpe1.GraphAxis.Count - 1) do

begin

  if (Crpe1.GraphAxis[cnt].SectionAsCode mod 1000 = 25) then

Crpe1.GraphAxis[cnt].GridLineX := gglMajorAndMinor;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;

The logic behind the math expression is based on the fact that each sub-section increments the Section Code number by 25 (from 0 to 975 are the possible numbers).  So, since 3000 is the general Section Code start number for a Group Header, and is therefore the number to represent GroupHeader 1a, 3025 represents GroupHeader 1b, 3050 represents GroupHeader 1c, etc.  Therefore, in order to find the "b" sections we must divide by 1000, and if the remainder is 25, it is a "b" section.  This formula also works for Sections that do not have Group options, such as Details (Da = 4000, Db = 4025, etc.).


SectionType method

See also

Applies to

GraphAxis

Declaration

property SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1a, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.


SectionType method - See also
Related

Section

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method

See also	Example

Applies to

GraphAxis

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Graph Axis information from the Report and stores it in the GraphAxis object.  If GraphAxis information was not found, the call returns False.


Retrieve method - See also
Related

Add

Clear

Send

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

    Crpe1.Subreports[cnt].GraphAxis.Retrieve;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Count method

See also	Example

Applies to

GraphAxis

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the GraphAxis object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphAxis.Retrieve;

  for cnt := 0 to (Crpe1.GraphAxis.Count - 1) do

    Crpe1.GraphAxis[cnt].DivisionsY := 5;

end;


Clear method

See also	Example

Applies to

GraphAxis

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GraphAxis object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the GraphAxis properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.GraphAxis.Clear;

This code clears the GraphAxis objects for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

  Crpe1.Subreports[cnt].GraphAxis.Clear;


Add method

See also	Example

Applies to

GraphAxis

Declaration

function Add(GraphNumber: TCrGraphAxisNumber): integer;

Type

TCrGraphAxisNumber = integer;

Description

The Add method manually adds an item to the GraphAxis object and sets the internal index to that item.  It requires a Graph number as a parameter, which should be a number corresponding to a Graph that exists in the Report.  The VCL Component numbers Graphs in a Report from Top to Bottom, Left to Right.

The steps to using the Add method with GraphAxis are:

1. Add an item to the GraphAxis object (you must specify the Graph Number).

2. Fill the desired GraphAxis properties with values.

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Graph Numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

The Add method can be used to manually add an item to the GraphAxis object:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Add(0);

Crpe1.GraphAxis.NumberFormatY := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


Delete method

See also	Example

Applies to

GraphAxis

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the GraphAxis object.  The "nIndex" parameter represents the order of the item in the GraphAxis object, which should not be confused with the Graph Number value.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the GraphAxis object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Graph number - must be same as in Report}

Crpe1.GraphAxis.Add(0);

{Section must also be specified when using Add}

Crpe1.GraphAxis.Section := 'PH';

Crpe1.GraphAxis.NumberFormatY := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.GraphAxis.Delete(0);


IndexOf method

See also	Example

Applies to

GraphAxis

Declaration

function IndexOf(GraphNumber: TCrGraphAxisNumber): integer;

Type

TCrGraphAxisNumber = integer;

Description

The IndexOf method takes a Graph number and returns the index position of the Graph item in the current GraphAxis object.

After the Retrieve method has been called, the GraphAxis object contains one item for each Graph in the Report.  The IndexOf method can be used to determine if a given Graph Number actually exists in the GraphAxis object before trying to access it.


IndexOf method - See also
Related

Number

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

The following code illustrates the use of the IndexOf method to locate a specific GraphAxis item by its number:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphAxis.Retrieve;

{Find a specific Graph}

nItem := Crpe1.GraphAxis.IndexOf(2);

{If it exists, change the Graph}

if nItem > -1 then

Crpe1.GraphAxis[nItem].NumberFormatY := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Send method

See also	Example

Applies to

GraphAxis

Declaration

function Send: boolean;

Description

The Send method sends the GraphAxis values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called (provided that SendOnExecute is set to True).


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the GraphAxis settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.GraphAxis.Send;


CopyFrom method

See also	Example

Applies to

GraphAxis

Declaration

procedure CopyFrom(Source: TCrpeGraphAxis);

Description

The CopyFrom method copies the GraphAxis property values from another TCrpeGraphAxis object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the GraphAxis property values to a temporary TCrpeGraphAxis object:

var

tempGraphAxis : TCrpeGraphAxis;

begin

tempGraphAxis := TCrpeGraphAxis.Create;

tempGraphAxis.CopyFrom(Crpe1.GraphAxis);

{...later, when finished with the temp object...}

tempGraphAxis.Free;

end;


Create method

See also

Applies to

GraphAxis

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the GraphAxis object, and does not need to be called in code, unless you are using the CopyFrom method to store GraphAxis data to a temporary object:

var

tempGraphAxis : TCrpeGraphAxis;

begin

tempGraphAxis := TCrpeGraphAxis.Create;

tempGraphAxis.CopyFrom(Crpe1.GraphAxis);

end;


Create method - See also
Related

CopyFrom

Destroy

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

GraphAxis

Declaration

destructor Destroy;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
Related

Create

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GraphOptionInfo

See also	Properties & Methods	Example

Declaration

property GraphOptionInfo: TCrpeGraphOptionInfo;

Type

TCrpeGraphOptionInfo = class(TPersistent)

Description

Only available with SCR 7 and higher.  The GraphOptionInfo class consists of the following properties:

•	The Number property specifies the Graph Number, and can be used as a lookup value to point the GraphOptionInfo object to a specific GraphOptionInfo item.  See How Graphs are Numbered for more information on the numbering scheme.

•	The Section property specifies the section that the Graph is located in, and uses the "short" section naming convention used in the Crystal Reports Designer.  See "About Section Names" for more information.

•	The Retrieve method can be used to fill the GraphOptionInfo object with information from the Report.

•	The Count method will indicate how many GraphOptionInfo items are currently in the GraphOptionInfo object.

•	The Item and ItemIndex properties can be used to navigate through the GraphOptionInfo items in the GraphOptionInfo object.

•	The Color property specifies whether the Graph will appear in Color or in Black & White.

•	The Legend property controls whether the Legend will be visible or not.

•	The PieSize, and PieSlice properties control certain features of Pie Graphs.

•	The BarSize, and BarDirection properties control certain features of Bar Graphs.

•	The DivisionTypeY, DivisionTypeY2, DivisionTypeZ properties specify  whether the value axis divisions (the y axis on a vertical bar graph) of the Graph are placed automatically, or whether the frequency of their spacing can be set manually.

•	The MarkerSize, and MarkerShape properties control the type of Markers that appear on the Legend and on the data points of some types of Graphs (Line, Radar, etc.).

•	The DataPoints property determines if there are labels or numeric values on the data points of the Graph.

•	The NumberFormat property determines the style of the numeric values on the data points of the Graph (only applicable if DataPoints are active).

•	The ViewingAngle property controls the angle and shape of 3D Graphs.


GraphOptionInfo - See also
Related

GraphAxis

GraphText

GraphType

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


GraphOptionInfo - Properties & Methods
GraphOptionInfo:

Properties & Methods

GraphOptionInfo	TCrpe Component

Properties

BarDirection

BarSize

Color

DataPoints

Legend

MarkerShape

MarkerSize

NumberFormat

PieSize

PieSlice

ViewingAngle

Key

Number

Navigation

Item

ItemIndex

Section

Section

SectionAsCode

SectionGraphNum

Methods

Clear

CopyFrom

Count

IndexOf

Retrieve

SectionType

Send

Manual

Add

Delete

Constructor

Create

Destructor

Destroy


GraphOptionInfo - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].Color := gcMonochrome;

Crpe1.GraphOptionInfo[0].Legend := glUpperRight;

Crpe1.GraphOptionInfo[0].PieSize := gpsMaximum;

Crpe1.GraphOptionInfo[0].PieSlice := gslLarge;

Crpe1.Output := toWindow;

Crpe1.Execute;


Number property

See also	Example

Applies to

GraphOptionInfo

Declaration

property Number: TCrGraphOptionInfoNumber;

Type

TCrGraphOptionInfoNumber = integer;

Description

The Number property specifies the Graph Number.

•	If the Retrieve method is used to fill the GraphOptionInfo object with infomation from the Report, each GraphOptionInfo item will have a unique Graph Number assigned by the VCL.

•	If the manual Add method is used instead, a Graph number will have to be specifed which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered).

The primary use of the Number property is as a look-up to point the GraphOptionInfo object to the item with the Graph number specified.  The default array property, Item, however, provides an easier way to navigate through the object.


Number property - See also
Related

Item

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Number property - Example
Example

This example retrieves the GraphOptionInfo values from the Report, and uses the Number property to navigate to the first Graph:

Crpe1.ReportName := 'C:\Company.rpt';

{Retrieve the GraphOptionInfo from the Report}

Crpe1.GraphOptionInfo.Retrieve;

{Set the GraphOptionInfo object to first Graph}

Crpe1.GraphOptionInfo.Number := 0;

{Change the properties of the Graph}

Crpe1.GraphOptionInfo.Legend := glUpperRight;

Crpe1.GraphOptionInfo.ViewingAngle := gvaBirdsEye;

Crpe1.Output := toWindow;

Crpe1.Execute;


Section property

See also	Example

Applies to

GraphOptionInfo

Declaration

property Section: string;

Description

The Section property contains the Section name of the item that the GraphOptionInfo object is currently pointed to.  It indicates in which Section of the Report that the Graph is located.

Note that you cannot move a Graph from one Section to another by changing this property.  It should primarily be used as a read-only property after the GraphOptionInfo information has been retrieved with the Retrieve method.  If the manual Add method is used to add items to the GraphOptionInfo object, then Section will have to be assigned the correct value in code.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH	- Report Header

PH	- Page Header

GH	- Group Header

D	- Details

GF	- Group Footer

PF	- Page Footer

RF	- Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections.  Numbers are used to designate different Groups: GH1, GF2, etc.  See About Section Names for more details on the syntax.


Section property - See also
Related

About Section Names

IndexOf

SectionAsCode

SectionType

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


Section property - Example
Example

In the following example, the Section property is used to apply changes only to Graphs which exist in a given Report Section (Page Header in this case):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

for cnt := 0 to (Crpe1.GraphOptionInfo.Count - 1) do

begin

  if Crpe1.GraphOptionInfo[cnt].Section = 'PH' then

    Crpe1.GraphOptionInfo[cnt].BarDirection := bdHorizontal;

end;

Crpe1.Output := toWindow;

Crpe1.Execute;


Color property

See also	Example

Applies to

GraphOptionInfo

Declaration

property Color: TCrGraphColor;

Type

TCrGraphColor = (gcDefault, gcColor, gcMonochrome);

Description

The Color property controls whether the Graph will appear in Color or in Monochrome.  Use gcDefault to leave the Graph in it's current color scheme.

The Monochrome setting is useful for printers that cannot handle color very well.  The various colors on the Graph will be replaced by different black/white shades and patterns.


Color property - See also
Related

Legend

See also

Properties by Group

Methods by Group

Methods

Events

Back to Start


Color property - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].Color := gcMonochrome;

Crpe1.GraphOptionInfo[0].Legend := glUpperRight;

Crpe1.GraphOptionInfo[0].PieSize := gpsMaximum;

Crpe1.GraphOptionInfo[0].PieSlice := gslLarge;

Crpe1.Output := toWindow;

Crpe1.Execute;


Legend property

See also	Example

Applies to

GraphOptionInfo

Declaration

property Legend: TCrGraphLegend;

Type

TCrGraphLegend = (glDefault, glNone, glUpperRight, glBottomCenter, glTopCenter, glRight, glLeft);

Description

The Legend property controls the placement of the Graph Legend, or whether it is visible at all.


Legend property - See also
Related

Color

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Legend property - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].Color := gcMonochrome;

Crpe1.GraphOptionInfo[0].Legend := glUpperRight;

Crpe1.GraphOptionInfo[0].PieSize := gpsMaximum;

Crpe1.GraphOptionInfo[0].PieSlice := gslLarge;

Crpe1.Output := toWindow;

Crpe1.Execute;


PieSize property

See also	Example

Applies to

GraphOptionInfo

Declaration

property PieSize: TCrGraphPieSize;

Type

TCrGraphPieSize = (gpsDefault, gpsMinimum, gpsSmall, gpsAverage, gpsLarge, gpsMaximum);

Description

The PieSize property controls the size of a Pie Graph.


PieSize property - See also
Related

PieSlice

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PieSize property - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].Color := gcMonochrome;

Crpe1.GraphOptionInfo[0].Legend := glUpperRight;

Crpe1.GraphOptionInfo[0].PieSize := gpsMaximum;

Crpe1.GraphOptionInfo[0].PieSlice := gslLarge;

Crpe1.Output := toWindow;

Crpe1.Execute;


PieSlice property

See also	Example

Applies to

GraphOptionInfo

Declaration

property PieSlice: TCrGraphPieSlice;

Type

TCrGraphPieSlice = (gslDefault, gslNone, gslSmall, gslLarge);

Description

The PieSlice property controls whether the smallest or largest slice of a Pie Graph will be slightly detached from the rest of the Pie.


PieSlice property - See also
Related

PieSize

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PieSlice property - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].Color := gcMonochrome;

Crpe1.GraphOptionInfo[0].Legend := glUpperRight;

Crpe1.GraphOptionInfo[0].PieSize := gpsMaximum;

Crpe1.GraphOptionInfo[0].PieSlice := gslLarge;

Crpe1.Output := toWindow;

Crpe1.Execute;


BarSize property

See also	Example

Applies to

GraphOptionInfo

Declaration

property BarSize: TCrGraphBarSize;

Type

TCrGraphBarSize = (gbsDefault, gbsMinimum, gbsSmall, gbsAverage, gbsLarge, gbsMaximum);

Description

The BarSize property determines the width (or thickness) of the bars in a Bar Graph.


BarSize property - See also
Related

BarDirection

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


BarSize property - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].BarSize := gbsAverage;

Crpe1.GraphOptionInfo[0].BarDirection := bdVertical;

Crpe1.Output := toWindow;

Crpe1.Execute;


BarDirection property

See also	Example

Applies to

GraphOptionInfo

Declaration

property BarDirection: TCrGraphBarDirection;

Type

TCrGraphBarDirection = (bdHorizontal, bdVertical, bdDefault);

Description

The BarDirection property determines whether a Bar Graph will run its bars horizontally or vertically.


BarDirection property - See also
Related

BarSize

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


BarDirection property - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].BarSize := gbsAverage;

Crpe1.GraphOptionInfo[0].BarDirection := bdVertical;

Crpe1.Output := toWindow;

Crpe1.Execute;


MarkerSize property

See also	Example

Applies to

GraphOptionInfo

Declaration

property MarkerSize: TCrGraphMarkerSize;

Type

TCrGraphMarkerSize = (gmsDefault, gmsSmall, gmsMediumSmall, gmsMedium, gmsMediumLarge, gmsLarge);

Description

The MarkerSize property affects the size of the markers in a Graph.  These markers appear at the data points of certain Graph Types such as Line or Radar.


MarkerSize property - See also
Related

MarkerShape

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


MarkerSize property - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].MarkerSize := gmsMediumSmall;

Crpe1.GraphOptionInfo[0].MarkerShape := gshDiamond;

Crpe1.Output := toWindow;

Crpe1.Execute;


MarkerShape property

See also	Example

Applies to

GraphOptionInfo

Declaration

property MarkerShape: TCrGraphMarkerShape;

Type

TCrGraphMarkerShape = (gshDefault, gshRectangle, gshCircle, gshDiamond, gshTriangle);

Description

The MarkerShape property determines the shape of the markers in a Graph.  These markers appear at the data points of certain Graph Types such as Line or Radar.

Note

MarkerShape also affects the markers in the Graph Legend, and the shape of the bars in a Bar Graph.


MarkerShape property - See also
Related

MarkerSize

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


MarkerShape property - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].MarkerSize := gmsMediumSmall;

Crpe1.GraphOptionInfo[0].MarkerShape := gshDiamond;

Crpe1.Output := toWindow;

Crpe1.Execute;


DataPoints property

See also	Example

Applies to

GraphOptionInfo

Declaration

property DataPoints: TCrGraphDataPoints;

Type

TCrGraphDataPoints = (gdpDefault, gdpNone, gdpShowLabel, gdpShowValue);

Description

The DataPoints property determines if there is an extra label or value displayed on the Data Points of a Graph.  The possible values are:

gdpDefault	- Leave the DataPoints setting as currently defined in the Graph.

gdpNone	- No DataPoints Label or Value will be displayed.

gdpShowLabel	- A Label will be displayed on the DataPoints which represents the operation used to determine the DataPoints (summary, count, etc.)

gdpShowValue	- A Value will be displayed on the DataPoints.  This value is the actual amount of the DataPoint.  The NumberFormat property determines the formatting of this value.


DataPoints property - See also
Related

NumberFormat

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DataPoints property - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].DataPoints := gdpShowValue;

Crpe1.GraphOptionInfo[0].NumberFormat := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


NumberFormat property

See also	Example

Applies to

GraphOptionInfo

Declaration

property NumberFormat: TCrGraphNumberFormat;

Type

TCrGraphNumberFormat = (gnfDefault, gnfNoDecimal, gnfOneDecimal, gnfTwoDecimal, gnfCurrencyNoDecimal, gnfCurrencyTwoDecimal, gnfPercentNoDecimal, gnfPercentOneDecimal, gnfPercentTwoDecimal);

Description

The NumberFormat property determines the formatting of the numbers that comprise the DataPoints Value (assuming DataPoints is set to gdpShowValue).


NumberFormat property - See also
Related

DataPoints

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


NumberFormat property - Example
Example

How to set GraphOptionInfo properties:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].DataPoints := gdpShowValue;

Crpe1.GraphOptionInfo[0].NumberFormat := gnfCurrencyTwoDecimal;

Crpe1.Output := toWindow;

Crpe1.Execute;


ViewingAngle property

See also	Example

Applies to

GraphOptionInfo

Declaration

property ViewingAngle: TCrGraphViewingAngle;

Type

TCrGraphViewingAngle = (gvaDefault, gvaStandard, gvaTall, gvaTop, gvaDistorted, gvaShort, gvaGroupEye, gvaGroupEmphasis, gvaFewSeries, gvaFewGroups, gvaDistortedStd, gvaThickGroups, gvaShorter, gvaThickSeries, gvaThickStd, gvaBirdsEye, gvaMax);

Description

The ViewingAngle property controls the angle and shape of 3D Graphs.


ViewingAngle property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ViewingAngle property - Example
Example

How to set the ViewingAngle property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

Crpe1.GraphOptionInfo[0].ViewingAngle := gvaThickSeries;

Crpe1.Output := toWindow;

Crpe1.Execute;


SectionGraphNum property

See also	Example

Applies to

GraphOptionInfo

Declaration

property SectionGraphNum: smallint;

Description

The SectionGraphNum property specifies the Graph Number as numbered from left to right within the Section it resides.  This is the numbering scheme used by the Print Engine, however the Crystal VCL also uses its own numbering scheme which is reflected in the Number property (so that each Graph has a unique number).

•	If the Retrieve method is used to fill the GraphType object with infomation from the Report, the SectionGraphNum values are retrieved automatically.

•	If the manual Add method is used instead, a SectionGraphNum value will have to be specifed which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered).

This property is mainly provided for those who wish to use the manual Add method.


SectionGraphNum property - See also
Related

Item

ItemIndex

Number

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionGraphNum property - Example
Example

This example manually adds an item to the GraphOptionInfo class and sets the SectionGraphNum accordingly:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

nItem := Crpe1.GraphOptionInfo.Add(0);

Crpe1.GraphOptionInfo[nItem].SectionGraphNum := 0;

Crpe1.GraphOptionInfo[nItem].Section := 'PH';

Crpe1.GraphOptionInfo[nItem].ViewingAngle := gvaFewSeries;

Crpe1.Execute;

end;


ItemIndex property

See also	Example

Applies to

GraphOptionInfo

Declaration

property ItemIndex: integer;

Description

ItemIndex is a run-time only property which can be used to obtain the current GraphOptionInfo item number, or set the GraphOptionInfo object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox.  This Index is updated whenever the Item property is used (Expressions[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Expressions.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.


ItemIndex property - See also
Related

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ItemIndex property - Example
Example

The following code illustrates the use of the ItemIndex property to make sure the GraphOptionInfo object is pointing to the first Graph:

if Crpe1.GraphOptionInfo.ItemIndex <> 0 then

  Crpe1.GraphOptionInfo[0];


Item property

See also	Example

Applies to

GraphOptionInfo

Declaration

property Item[const nIndex: integer]: TCrpeGraphOptionInfo;

Description

The Item property is a default array property.  It is read-only, and only available at runtime.  It's primary use is to provide an easy way to navigate through the various items stored in the GraphOptionInfo object, allowing the object to be treated like an array.

•	Item is a default property, so it does not need to be specified when using the subscript:  GraphOptionInfo[2] is the same as GraphOptionInfo.Item[2].

•	Item returns a reference to the GraphOptionInfo object, so the GraphOptionInfo properties can be used right after the subscript: GraphOptionInfo[2].Number := 1;


Item property - See also
Related

ItemIndex

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Item property - Example
Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

{Set GraphOptionInfo to the 1st Graph}

Crpe1.GraphOptionInfo.Item[0];

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

{Set GraphOptionInfo to the 1st Graph}

Crpe1.GraphOptionInfo[0];


SectionAsCode property

See also	Example

Applies to

GraphOptionInfo

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers.  Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names.


SectionAsCode property - See also
Related

Section

SectionType

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SectionAsCode property - Example
Example

The SectionAsCode property can be used to apply formula-based formatting to specific sections based on mathematical calculations or comparisons.  The following code checks each section to see if it is a "b" section, such as RHb, PHb, Db, etc, and if it is, the Graph properties are changed:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

for cnt := 0 to (Crpe1.GraphOptionInfo.Count - 1) do

begin

  if (Crpe1.GraphOptionInfo[cnt].SectionAsCode mod 1000 = 25) then

    Crpe1.GraphOptionInfo[cnt].ViewingAngle := gvaDistorted;

Crpe1.Output := toWindow;

Crpe1.Execute;

The logic behind the math expression is based on the fact that each sub-section increments the Section Code number by 25 (from 0 to 975 are the possible numbers).  So, since 3000 is the general Section Code start number for a Group Header, and is therefore the number to represent GroupHeader 1a, 3025 represents GroupHeader 1b, 3050 represents GroupHeader 1c, etc.  Therefore, in order to find the "b" sections we must divide by 1000, and if the remainder is 25, it is a "b" section.  This formula also works for Sections that do not have Group options, such as Details (Da = 4000, Db = 4025, etc.).


SectionType method

See also

Applies to

GraphOptionInfo

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier.  In other words, if the Section Code for an item is GH1a, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.


SectionType method - See also
Related

Section

SectionAsCode

StrToSectionCode

SectionCodeToStr

About Section Names

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method

See also	Example

Applies to

GraphOptionInfo

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the GraphOptionInfo information from the Report and stores it in the GraphOptionInfo object.  If Graph information was not found, the call returns False.


Retrieve method - See also
Related

Add

Clear

Send

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Retrieve method - Example
Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Subreports.Retrieve;

  {Loop through Reports and Retrieve}

  for cnt := 0 to (Crpe1.Subreports.Count - 1) do

    Crpe1.Subreports[cnt].GraphOptionInfo.Retrieve;

  {Set Crpe component back to main Report}

  Crpe1.Subreports[0];

end;


Count method

See also	Example

Applies to

GraphOptionInfo

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the GraphOptionInfo object.  It is handy for setting up loops to make similar changes to each item.


Count method - See also
Related

Item

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Count method - Example
Example

The Count method is useful for looping constructions.  You would normally want to call Retrieve first:

var

  cnt: integer;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.GraphOptionInfo.Retrieve;

  for cnt := 0 to (Crpe1.GraphOptionInfo.Count - 1) do

Crpe1.GraphOptionInfo[cnt].ViewingAngle := gvaGroupEmphasis;

end;


Clear method

See also	Example

Applies to

GraphOptionInfo

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GraphOptionInfo object.  It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.


Clear method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

This code clears the GraphOptionInfo properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.GraphOptionInfo.Clear;

This code clears the GraphOptionInfo for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do

  Crpe1.Subreports[cnt].GraphOptionInfo.Clear;


Add method

See also	Example

Applies to

GraphOptionInfo

Declaration

function Add(GraphNumber: TCrGraphOptionInfoNumber): integer;

Type

TCrGraphOptionInfoNumber = integer;

Description

The Add method manually adds an item to the GraphOptionInfo object and sets the internal index to that item.  It requires a Graph number as a parameter, which should be a number corresponding to a Graph that exists in the Report.

The steps to using the Add method with GraphOptionInfo are:

1. Add an item to the GraphOptionInfo object (you must specify the Graph number).

2. Fill the desired GraphOptionInfo properties with values.  Note that a SectionGraphNum value will have to be specifed which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered).

3. When Execute is called, the properties will be sent to the Print Engine.

Note

It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Graph numbers are correct for the current Report.


Add method - See also
Related

Delete

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Add method - Example
Example

This example manually adds an item to the GraphOptionInfo class and sets the SectionGraphNum accordingly:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

nItem := Crpe1.GraphOptionInfo.Add(0);

Crpe1.GraphOptionInfo[nItem].SectionGraphNum := 0;

Crpe1.GraphOptionInfo[nItem].Section := 'PH';

Crpe1.GraphOptionInfo[nItem].ViewingAngle := gvaFewSeries;

Crpe1.Execute;

end;


Delete method

See also	Example

Applies to

GraphOptionInfo

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the GraphOptionInfo object.  The "nIndex" parameter represents the order of the item in the GraphOptionInfo object, which should not be confused with the Graph Number value.


Delete method - See also
Related

Add

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Delete method - Example
Example

The Delete method can be used to manually remove an item from the GraphOptionInfo object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Graph number - must be same as in Report}

Crpe1.GraphOptionInfo.Add(0);

{Section and SectionGraphNum must also be specified when using Add}

Crpe1.GraphOptionInfo.SectionGraphNum := 0;

Crpe1.GraphOptionInfo.Section := 'PH';

Crpe1.GraphOptionInfo.BarDirection := bdVertical;

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.GraphOptionInfo.Delete(0);


IndexOf method

See also	Example

Applies to

GraphOptionInfo

Declaration

function IndexOf(GraphNumber: TCrGraphOptionInfoNumber): integer;

Type

TCrGraphOptionInfoNumber = integer;

Description

The IndexOf method takes a Graph number and returns the index position of the Graph item in the GraphOptionInfo object.

After the Retrieve method has been called, the GraphOptionInfo object contains one item for each Graph in the Report.  The IndexOf method can be used to determine if a given Graph Number actually exists in the GraphOptionInfo object before trying to access it.


IndexOf method - See also
Related

Number

Item

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IndexOf method - Example
Example

The following code illustrates the use of the IndexOf method to locate a specific GraphOptionInfo item by its number:

var

  nItem: integer;

begin

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphOptionInfo.Retrieve;

{Find a specific Graph}

nItem := Crpe1.GraphOptionInfo.IndexOf(2);

{If it exists, change the Graph properties}

if nItem > -1 then

Crpe1.GraphOptionInfo[nItem].BarDirection := bdVertical;

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Send method

See also	Example

Applies to

GraphOptionInfo

Declaration

function Send: boolean;

Description

The Send method sends the GraphOptionInfo values to the Crystal Reports Print Engine.  This method is called automatically when the Execute method is called (provided that SendOnExecute is set to True).


Send method - See also
Related

Retrieve

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Send method - Example
Example

In this example, the GraphOptionInfo settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.GraphOptionInfo.Send;


CopyFrom method

See also	Example

Applies to

GraphOptionInfo

Declaration

procedure CopyFrom(Source: TCrpeGraphOptionInfo);

Description

The CopyFrom method copies the GraphOptionInfo property values from another TCrpeGraphOptionInfo object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
Related

TCrpe.CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the GraphOptionInfo property values to a temporary TCrpeGraphOptionInfo object:

var

tempGraphInfo : TCrpeGraphOptionInfo;

begin

tempGraphInfo := TCrpeGraphOptionInfo.Create;

tempGraphInfo.CopyFrom(Crpe1.GraphOptionInfo);

{...later, when finished with the temp object...}

tempGraphInfo.Free;

end;


Create method

See also

Applies to

GraphOptionInfo

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the GraphOptionInfo object, and does not need to be called in code, unless you are using the CopyFrom method to store GraphOptionInfo data to a temporary object:

var

  tempGOption : TCrpeGraphOptionInfo;

begin

  tempGOption := TCrpeGraphOptionInfo.Create;

  tempGOption.CopyFrom(Crpe1.GraphOptionInfo);

end;


Create method - See also
Related

CopyFrom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Destroy method

See also

Applies to

GraphOptionInfo

Declaration

destructor Destroy;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

Note

The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it.  The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.


Destroy method - See also
Related

Create

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


About property

See also

Declaration

property About: TCrpeAboutBox;

Types

TCrpeAboutBox = class(TForm)

Description

The About property is the first property in the Object Inspector and launches a Dialog which shows the Version number of the Crystal Reports Component.  The Version number is divided into four parts, ie:

7.4.0.0

The first number represents the highest Seagate Crystal Reports version supported:

5	=	SCR 5

6	=	SCR 6

7	=	SCR 7

The second number represents the Delphi version:

2	=	Delphi 2

3	=	Delphi 3

4	=	Delphi 4

The third number represents the VCL release version:

0	=	First release

The fourth number represents the release build-version:

0	=	First release build


About property - See also
Related

Version

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CanCloseEngine property

See also	Example

Declaration

property CanCloseEngine: boolean;

Description

CanCloseEngine is a runtime, read-only property that determines whether or not the Crystal Reports Print Engine can be closed.  Use this function before calling CloseEngine to verify that the engine is no longer processing print jobs. If the Print Engine closes while a print job is still running, an error can occur in your application or on the user's system.

Note:  the Crystal component will automatically close the Print Engine when it's Destroy method is called, or when the Form it is on is destroyed.


CanCloseEngine property - See also
Related

IsJobFinished

PrintEnded

Status

OnWindowClose

OnPrintEnded

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CanCloseEngine property - Example
Example

The CanCloseEngine property can be used to determine if the Print Engine is done processing jobs.  In this example the VCL is dynamically created and freed:

var

  Crpe1: TCrpe;

begin

Crpe1 := TCrpe.Create(Self);

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

while not Crpe1.CanCloseEngine do

  Application.ProcessMessages;

Crpe1.Free;

end;

Note that in the example above, the CanCloseEngine will not return True until all Print Jobs are finished processing.  Other properties such as IsJobFinished, PrintEnded, and Status will work on just the current Print Job, and could be used instead.


DesignControls property

See also

Declaration

property DesignControls: TCrpeDesignControlsDlg;

Types

TCrpeDesignControlsDlg = class(TForm)

Description

The DesignControls property is a design-time only property.  Clicking the dialog button on the Object Inspector, or running it from the component menu (right-click on the component to get the menu), will bring up a small button-bar dialog which can be used to load, retrieve, run, and page through Reports at design-time.

Report Buttons

These buttons are on the first row of the DesignControls dialog and control the opening, closing, retrieving and running of Reports from the Delphi design-time editor.

Open Report

This button brings up the OpenDialog to choose a Report to load.  It will update the ReportName property with the new choice.

Close Report

This button closes the currently open Report, and clears the ReportName property.  It is equivalent to calling CloseWindow, CloseJob, and clearing ReportName in code.

Retrieve Data

This button brings up the Retrieve dialog:

This dialog allows you to choose which items you would like to Retrieve the Report Data for. Any items that are checked will have their data retrieved from the Report into the VCL when the Retrieve button is clicked.  From there, the data can be edited in the Object Inspector, and then the Report can be Previewed to see the effect of the changes.

Quick Preview

This button runs the Report to whichever destination is specified in the Output property.

Preview Report

This button runs the Report to Preview Window.  If the WindowParent property has been set to the current Form, or a Panel on the Form, the Preview Window will be attached to that Form or Panel.  When the Preview Window is attached to another Form or Panel, the Window controls will be inaccessible at design-time.  Therefore, the other buttons on the DesignControls dialog can be used to page through or close the Preview Window.

Print Report

This button runs the Report to a printer.  The Print Dialog will appear to allow you to choose the destination printer.

Export Report

This button exports the Report.  You will be prompted for the Export options.  This is accomplished by setting

the PromptForOptions property of the Export object to True.

Window Buttons

These buttons are on the second row of the DesignControls dialog and control the closing, paging and zoom level of the Preview Window of a Report run from the DesignControls dialog.  These controls are especially useful when the WindowParent property has been set to a Form or Panel, in which case the Preview Window controls will not be accessible at design-time.

Close Window

This button can be used to close the currently open Preview Window.

First Page

This button can be used to go to the first page of the currently open Preview Window.

Previous Page

This button can be used to go to the previous page of the currently open Preview Window.

Next Page

This button can be used to go to the next page of the currently open Preview Window.

Last Page

This button can be used to go to the last page of the currently open Preview Window.

Cancel

This button can be used to cancel the processing of a Report after the Preview, Print, or Export buttons

have been clicked.  It is equivalent to calling CancelJob in code.

Zoom

This button changes the Zoom level of the currently open Preview Window.


DesignControls property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DesignControls property - Open Report
Open Report

This button brings up the OpenDialog to choose

a Report to load.  It will update the ReportName

property with the new choice.


DesignControls property - Close Report
Close Report

This button closes the currently open Report, and

clears the ReportName property.  It is equivalent to

calling CloseWindow, CloseJob, and clearing

ReportName in code.


DesignControls property - Retrieve Data
Retrieve Data

This button brings up the Retrieve dialog:

This dialog allows you to choose which items you would like to Retrieve the Report Data for.

Any items that are checked will have their data retrieved from the Report into the VCL when

the Retrieve button is clicked.  From there, the data can be edited in the Object Inspector,

and then the Report can be Previewed to see the effect of the changes.


DesignControls property - Quick Preview
Quick Preview

This button runs the Report to whichever destination

is specified in the Output property.


DesignControls property - Preview Report
Preview Report

This button runs the Report to Preview Window.

If the WindowParent property has been set to the

current Form, or a Panel on the Form, the Preview

Window will be attached to that Form or Panel.

When the Preview Window is attached to another

Form or Panel, the Window controls will be inaccessible

at design-time.  Therefore, the other buttons on the

DesignControls dialog can be used to page through or

close the Preview Window.


DesignControls property - Print Report
Print Report

This button runs the Report to a printer.  The Print

Dialog will appear to allow you to choose the

destination printer.


DesignControls property - Export Report
Export Report

This button exports the Report.  You will be prompted

for the Export options.  This is accomplished by setting

the PromptForOptions property of the Export object

to True.


DesignControls property - Close Window
Close Window

This button can be used to close the currently open

Preview Window.  It is especially useful when the

WindowParent property has been set to a Form

or Panel, in which case the Preview Window controls

will not be accessible at design-time.


DesignControls property - First Page
First Page

This button can be used to go to the first page of

the currently open Preview Window.  It is especially

useful when the WindowParent property has been

set to a Form or Panel, in which case the Preview

Window controls will not be accessible at design-time.


DesignControls property - Previous Page
Previous Page

This button can be used to go to the previous page of

the currently open Preview Window.  It is especially

useful when the WindowParent property has been

set to a Form or Panel, in which case the Preview

Window controls will not be accessible at design-time.


DesignControls property - Next Page
Next Page

This button can be used to go to the next page of

the currently open Preview Window.  It is especially

useful when the WindowParent property has been

set to a Form or Panel, in which case the Preview

Window controls will not be accessible at design-time.


DesignControls property - Last Page
Last Page

This button can be used to go to the last page of

the currently open Preview Window.  It is especially

useful when the WindowParent property has been

set to a Form or Panel, in which case the Preview

Window controls will not be accessible at design-time.


DesignControls property - Cancel
Cancel

This button can be used to cancel the processing

of a Report after the Preview, Print, or Export buttons

have been clicked.  It is equivalent to calling CancelJob

in code.


DesignControls property - Zoom
Zoom

This button changes the Zoom level of the currently

open Preview Window.  It is equivalent to calling

WindowZoom.NextLevel in code, and is especially

useful when the WindowParent property has been

set to a Form or Panel, in which case the Preview

Window controls will not be accessible at design-time.


DetailCopies property

See also	Example

Declaration

property DetailCopies: integer;

Description

The DetailCopies property determines how many times the Details band of the Report will print out.

•	Normally used for Mailing-Label style Reports, where more than one label may be desired for each customer in a list.

•	Can also be applied to Subreports.

•	Default value for DetailCopies is 1.


DetailCopies property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DetailCopies property - Example
Example

This code sample sets the DetailCopies to 2.  The Details area of the Report will be printed out twice per record.

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.DetailCopies := 2;

Crpe1.Output := toPrinter;

Crpe1.Execute;


DialogParent property

See also	Example

Declaration

property DialogParent: TCrWinControl;

Type

TCrWinControl = TWinControl;

Description

DialogParent causes the Preview Window dialogs to have the same Z-Order as the Parent Form they are attached to.  Z-Order affects the order in which windows are drawn on the screen, so in this case, the Preview Window dialogs would be brought to the front of the screen when the Parent Form is brought to the front.  In this situation, care must be taken not to close the Parent Form while the Crystal Preview Window is writing to one of the dialogs.

To set DialogParent, simply assign it the name of the Form or Panel desired.


DialogParent property - See also
Related

SendDialogParent

WindowParent

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DialogParent property - Example
Example

In this example. the Preview Window dialogs will have the same Z-Order as Form1:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.DialogParent := Form1;

Crpe1.Output := toWindow;

Crpe1.Execute;


DiscardSavedData property

See also	Example

Declaration

property DiscardSavedData: boolean;

Description

A Report can be created with Saved Data.  This means that the data it was last run with is saved with the Report, and unless it is discarded, the Report will by default run with the Saved Data instead of reading the Database.  This is sometimes desirable, such as when a Report is being distributed to users who do not have access to the Database but would like to preview and print the Reports anyway.

In most other cases, applications that call Reports should make sure they discard the Saved Data.  Using the DiscardData method, or setting the DiscardSavedData property to True will do that.  The DiscardData method works immediately on the open Report, whereas the DiscardSavedData property only acts when Crpe1.Execute is called.

The HasSavedData property can be checked to see if the Report has Saved Data or not.

Note

If a Report is executed at runtime, and it is still the currently loaded Report in the VCL, running it again will cause it to use the Saved Data from the previous run.  Therefore, if running a Report more than once in a row, with different parameters, make sure and either call DiscardData or set DiscardSavedData to True between each run.


DiscardSavedData property - See also
Related

DiscardData

HasSavedData

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DiscardSavedData property - Example
Example

This code example sets the DiscardSavedData property to True.  Any data saved with the Report, either when the Report was saved in Crystal Reports Designer, or because the Report was run once already, will be discarded when Crpe1.Execute is called:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.DiscardSavedData := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


HasSavedData property

See also	Example

Declaration

property HasSavedData: boolean;

Description

The HasSavedData property is a read-only property that queries the Report loaded to determine if it has Saved Data or not.

When a Report is saved in the Crystal Designer with Saved Data turned on, the data it was last run with is saved with the Report, and unless it is discarded, the Report will by default run with the Saved Data instead of reading the Database.  This is sometimes desirable, such as when a Report is being distributed to users who do not have access to the Database but would like to preview and print the Reports anyway.

In most other cases, the Saved Data should be discarded so that the data is refreshed with new values from the database.  The HasSavedData property can be used in conjunction with the DiscardSavedData property or the DiscardData method to accomplish this.


HasSavedData property - See also
Related

DiscardData

DiscardSavedData

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


HasSavedData property - Example
Example

In the following example, if the Report has Saved Data, it will be discarded immediately:

Crpe1.ReportName := 'C:\Company.rpt';

if Crpe1.HasSavedData then

  Crpe1.DiscardData;

Crpe1.Output := toWindow;

Crpe1.Execute;

In this example, if the Report has Saved Data, it will be discarded when Crpe1.Execute is called:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.DiscardSavedData := Crpe1.HasSavedData;

Crpe1.Output := toWindow;

Crpe1.Execute;


IsJobFinished property

See also	Example

Declaration

property IsJobFinished: boolean;

Description

IsJobFinished is a run-time, read-only property that monitors the Print Job to see if it is finished or still in progress. You can use this function any time you have a call that is contingent on a Print Job being finished.  It would normally be checked after the Execute method has been called.

If the Output is set to go toWindow, IsJobFinished will return True immediately after the Report has been displayed in the Preview Window, even if that Preview Window has not been closed yet.  To check for window close, use the OnWindowClose event, or the ReportWindowHandle method.


IsJobFinished property - See also
Related

CanCloseEngine

PrintEnded

Status

OnWindowClose

OnPrintEnded

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


IsJobFinished property - Example
Example

The following code example shows how to use the IsJobFinished property to determine if a Print Job is finished processing:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

Crpe1.Execute;

while not Crpe1.IsJobFinished do

  Application.ProcessMessages;

Crpe1.CloseJob;


JobNumber property

See also	Example

Declaration

property JobNumber: Word;

Description

The JobNumber property is a run-time, read-only property that returns the number assigned by the Crystal Reports Print Engine to the current Report Print Job.

Each time a Report (or a Subreport) is opened, the Print Engine assigns it a specific number which is used when passing values back to the Print Engine.  This number is handled internally in the Crystal component and does not normally need to be accessed by the user.

Because the JobNumber is now a public property, it is possible to use this number to make calls directly to the Crystal Reports Print Engine DLL, just as the component does internally.  However, since the component now offers practically all the functionality of the Print Engine DLL calls, with much less work, it is usually not necessary to do so.  Also, care must be taken not to make changes via direct calls to the Print Engine that might confuse the VCL, such as closing the PrintJob.

See the OnJobOpened event for more information.


JobNumber property - See also
Related

OpenJob

CloseJob

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


JobNumber property - Example
Example

In this example, the current Print Job number will be shown:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.OpenJob;

ShowMessage(IntToStr(Crpe1.JobNumber));


LastErrorNumber property

See also	Example

Declaration

property LastErrorNumber: integer;

Description

The LastErrorNumber property is a run-time only property which holds the number of the last error that occured after calling the Execute method.  There are two types of errors that can occur in the Crystal component:

1. Errors that occur in the Print Engine - these have Error Number values of 500 or greater.

2. Errors that occur in the Crystal component - these have Error Number values of 100 to 400.

When a Print Engine error occurs, the component raises an Error exception, which would normally display a Dialog box with the Error Number and Error String displayed.  By using the OnError event, this exception can be by-passed, or a custom dialog can be used instead.  If the exception is by-passed, the internal procedure that the error occured in will either be exited, or if it is a loop, will proceed to the next iteration.  See OnError for more details.

LastErrrorString can also be used to obtain the text string of the Error message.


LastErrorNumber property - See also
Related

LastErrorString

OnError

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LastErrorNumber property - Example
Example

This example shows how to display the LastErrorNumber and LastErrorString.  Normally these would be handled by the internal Error exception:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Execute;

if Crpe1.LastErrorNumber > 0 then

  ShowMessage('Error ' + IntToStr(Crpe1.LastErrorNumber) +

  ': ' + Crpe1.LastErrorString);

end;


LastErrorString property

See also	Example

Declaration

property LastErrorString: string;

Description

The LastErrorString property is a run-time only property which holds the text message of the last error that occured after calling the Execute method.  There are two types of errors in the Crystal component:

1. Errors that occur in the Print Engine - these have Error Number values of 500 or greater.

2. Errors that occur in the Crystal component - these have Error Number values of 100 to 400.

When a Print Engine error occurs, the component raises an Error exception, which would normally display a Dialog box with the Error Number and Error String displayed.  By using the OnError event, this exception can be by-passed, or a custom dialog can be used instead.  If the exception is by-passed, the internal procedure that the error occured in will either be exited, or if it is a loop, will proceed to the next iteration.  See OnError for more details.

LastErrrorNumber can also be used to obtain the Error Number of the Error.


LastErrorString property - See also
Related

LastErrorNumber

OnError

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LastErrorString property - Example
Example

This example shows how to display the LastErrorNumber and LastErrorString.  Normally these would be handled by the internal Error exception:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Execute;

if Crpe1.LastErrorNumber > 0 then

  ShowMessage('Error ' + IntToStr(Crpe1.LastErrorNumber) +

  ': ' + Crpe1.LastErrorString);

end;


LoadEngineOnUse property

See also	Example

Declaration

property LoadEngineOnUse: boolean;

Description

The LoadEngineOnUse property determines if the Crystal Reports Print Engine DLL (CRPE32.DLL) is loaded into memory when the component is created.

•	If LoadEngineOnUse is set to True, the DLL will not be loaded until it is actually needed by the component (such as when retrieving values from a Report, or when running the Report).  This is useful in applications where the user may not be using the Reports section of the application, and therefore does not need the DLL loaded.

•	If LoadEngineOnUse is set to False, the DLL is loaded into memory at the time that the component is created.

Note

The DLL can also be unloaded by calling the CloseEngine method, or by Destroying the component, although this will also close any Reports that are currently open.


LoadEngineOnUse property - See also
Related

OpenEngine

CloseEngine

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LoadEngineOnUse property - Example
Example

In this example, the CRPE32.DLL will not load until Execute is called:

Crpe1.LoadEngineOnUse := True;

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;


Output property

See also	Example

Declaration

property Output: TCrOutput;

Types

TCrOutput = (toWindow, toPrinter, toExport);

Description

The Output property determines the destination of the Report when the Execute method is called.  The three possible values are:

toWindow 	: Sends the Report to a Preview Window (this is the default).

toPrinter 	: Sends the Report to the Printer.

toExport 	: Sends the Report to an Exported File, or to Email, or to an Exchange Folder.

toWindow

The following properties can be used to set the various Window options:  WindowButtonBar, WindowSize, WindowState, WindowStyle, WindowZoom, and WindowEvents.

toPrinter

The following properties can be used to set the various Printer options:  Printer, PrintOptions, and ProgressDialog.

toExport

The following properties can be used to set the various Printer options:  Export, and ProgressDialog.  The Destination property of the Export object determines whether the Report will go to disk File, or to Email, or to Exchange Folder.  The Export FileType property will determine the file format of the resulting exported Report.


Output property - See also
Related

Export

Printer

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Output property - Example
Example

In this example, the Output property is set toWindow.  When the Execute method is called, the Report will appear in a Preview Window:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;


PrintEnded property

See also	Example

Declaration

property PrintEnded: Boolean;

Description

PrintEnded is a run-time, read-only property that indicates when the Print Job is finished processing.  The value of this property is True when the Engine is done running the report.  When Output is set to go toWindow, this property will not return True until you have gone to the last page of the Report (use Status instead in this case).

Note that you can also use the OnPrintEnded event to the same effect.


PrintEnded property - See also
Related

CanCloseEngine

IsJobFinished

Status

OnWindowClose

OnPrintEnded

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintEnded property - Example
Example

This example sends the Report to the Printer.  It will not allow the program to close the current Form until the printing is finished.

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toPrinter;

Crpe1.Execute;

while not Crpe1.PrintEnded do

  Application.ProcessMessages;

Close;


ProgressDialog property

See also	Example

Declaration

property ProgressDialog: boolean;

Description

The ProgressDialog property determines if the Crystal Reports Print Engine internal Progress Dialog is displayed when a Report is run to Printer or to Export.  The Progress Dialog does not apply to Reports being run to Preview Window.  The default setting for this property is True.  The Progress Dialog looks like this:

See also: Creating a User-Defined Progress Dialog


ProgressDialog property - See also
Related

Export

Printer

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ProgressDialog property - Example
Example

This example sets the ProgressDialog to True.  The dialog will appear when the Report is being printed:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ProgressDialog := True;

Crpe1.Output := toPrinter;

Crpe1.Execute;


Progress Dialog - User-Defined
Creating a User-Defined Progress Dialog

The ProgressDialog can be replaced with a User-Defined dialog by setting ProgressDialog property to False, and creating a dialog that displays the values of the Records object after the Report has been started (Execute was called).

Step 1 : Create a Dialog form with a TTimer component and 3 labels.

Step 2 : In the OnCreate Event, enable the TTimer.

procedure TForm1.FormCreate(Sender: TObject);

begin

  Timer1.Enabled := True;

end;

Step 3 : In the OnShow Event, SetFocus to the Form (or ShowModal, or set FormStyle to AlwaysOnTop).

procedure TForm1.FormShow(Sender: TObject);

begin

  Form1.SetFocus;

end;

Step 4 : In the Timer's OnTimer Event, update the display.

procedure TfrmParentWindow.Timer1Timer(Sender: TObject);

var

  temp1,temp2,temp3: string;

begin

  {Update Status Display}

  Str(frmMain.Crpe1.Records.Printed, temp1);

  Str(frmMain.Crpe1.Records.Read, temp2);

  Str(frmMain.Crpe1.Records.Selected, temp3);

  labelRecordsPrinted.Caption := temp1 + ' ';

  labelRecordsRead.Caption := temp2 + ' ';

  labelRecordsSelected.Caption := temp3 + ' ';

end;


ReportName property

See also	Example

Declaration

property ReportName: TCrFileName;

Type

TCrFileName = string[TCRPE_FILENAME_LEN];

Constant

TCRPE_FILENAME_LEN = 255

Description

The ReportName property determines which Report is currently loaded.

•	ReportName should be the first property set in code, since it causes most of the others to be cleared.

•	Changing the ReportName will cause any currently open Report to be cleared from the VCL and closed in the Crystal Reports Print Engine.

•	After a new name has been assigned to ReportName, any previous Report that may still be displayed in a Preview Window will still be active in the Window until the Window is closed, although it can not be accessed via VCL code.

Note

A change in ReportName will normally cause the VCL properties applying to that Report to be cleared.  But if the same Report will be loaded twice in a row, there will not be a recognizable change in ReportName.  Under these circumstances, if it is desired that the current Print Job with it's parameters be cleared, two different methods can be used to close the current Print Job:

1. Set ReportName to a blank string between Reports:  Crpe1.ReportName := '';

2. Use the CloseJob method:  Crpe1.CloseJob;

Specifying Report Directory at Runtime

There are a number of ways of specifying the directory that the Reports will be located in at runtime, which could change depending on the installation directory chosen by the user.  If the Reports will be located in the Application directory, this code will obtain the path:

var

  RptDir: string;

begin

  RptDir := ExtractFilePath(Application.ExeName);

  Crpe1.ReportName := RptDir + 'Company.rpt';

end;

Another way of getting around the problem is to set up a BDE Alias to the Reports directory.  Then the GetPathFromAlias method can be used to obtain the Report path:

var

  RptDir: string;

begin

  RptDir := Crpe1.GetPathFromAlias(':RPTAlias:');

  Crpe1.ReportName := RptDir + 'Company.rpt';

end;


ReportName property - See also
Related

CancelJob

CloseJob

OpenJob

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ReportName property - Example
Example

In this example, the ReportName property is directly assigned a new Report name complete with path:

Crpe1.ReportName := 'C:\Reports\MyNewReport.rpt';

In this example, an OpenDialog is executed and the ReportName property is assigned the value of the file chosen from the dialog:

if OpenDialog1.Execute then

  Crpe1.ReportName := OpenDialog1.FileName;


ReportTitle property

See also	Example

Declaration

property ReportTitle: string;

Description

The ReportTitle is an internal name by which the Report is named.  In Seagate Crystal Reports designer, the ReportTitle is one of the Special Fields in the Crystal Reports Designer, which can be inserted into a Report and displayed.  For the main Report, this value can also be changed in the SummaryInfo Title property.

Take care when changing the ReportTitle for Subreports, since the ReportTitle is also used in two other objects:

1. The Subreports object has a Name property which corresponds to the same value as ReportTitle, in the Crystal Reports Print Engine.

2. The ParamFields object has a ReportName property which also corresponds to the same value as ReportTitle, in the Crystal Reports Print Engine.

Therefore, it is recommended that if a Subreport ReportTitle is changed, be sure to re-load the Report before attempting to run it twice in a row.

One interesting feature of this property is that Subreports can be renamed, which cannot be done within the Crystal Designer.  If the ReportTitle for a Subreport is changed, and then the Subreport is exported to CrystalReportsRPT format, the exported Report will have the Subreport names changed to match the values passed in the ReportTitle property.


ReportTitle property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ReportTitle property - Example
Example

The code below shows how to change the ReportTitle property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportTitle := 'Summary Report';

Crpe1.Output := toWindow;

Crpe1.Execute;


SendOnExecute property

See also	Example

Declaration

property SendOnExecute: Boolean;

Description

The SendOnExecute property determines if the settings stored in the Crystal Reports component are sent to the Crystal Reports Print Engine when the Execute method is called.  Normally this property should be left at it's default, which is True.

If SendOnExecute is set to False, each Sub-class property, and each property that does not belong to a Sub-class, must be sent manually to the Print Engine using the Send method before the Execute method is called.  This feature is provided mainly for debugging purposes.


SendOnExecute property - See also
Related

Execute

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SendOnExecute property - Example
Example

The code below illustrates the SendOnExecute property, although setting it to True is not normally necessary as this is it's default state:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SendOnExecute := True;

Crpe1.Output := toWindow;

Crpe1.Execute;


Status property

See also	Example

Declaration

property Status: integer;

Description

Status is a run-time, read-only property that can be used after the Execute method to indicate the processing status of the Report.  It will return an integer value from the following list:

0	- The Print Engine or the PrintJob are not open.

1	- The Job has not started yet.

2	- The Job is in progress.

3	- The Job has completed successfully.

4	- The Job has failed.

5	- The Job has been canceled by the user.

6 	- The Report has exceeded the record or time governors.

You can use this function in a number of programming situations, for example:

- to trigger error messages, i.e., when a print job fails (due to insufficient memory, insufficient disk space, etc.),

- to trigger screen displays (hourglass, series of graphics, etc.) that confirm to the user that work is in progress,

- to find out whether a job was canceled by the user after Execute.


Status property - See also
Related

CanCloseEngine

IsJobFinished

PrintEnded

OnWindowClose

OnPrintEnded

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Status property - Example
Example

The code below illustrates the use of Status to determine when the Job has completed:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

{Loop until the Job is finished processing}

while Crpe1.Status <> 3 do

  Application.ProcessMessages;

Crpe1.CloseJob;


WindowParent property

See also	Example

Declaration

property WindowParent: TCrWinControl;

Type

TCrWinControl = TWinControl;

Description

WindowParent is a run-time only property that can be used to attach the Crystal Preview Window to a Delphi Form.  This is useful when you want to create a custom button bar, or make the Crystal window an MDI child.

Dealing with MDI Forms

There are two options when using an MDI Form:

1. With version 7.x of the VCL, the WindowParent property now has built-in support for MDI forms.  If it detects that the Form specified in the WindowParent property is an MDI Form (FormStyle = fsMDIForm), it will create a Delphi MDI Child Form, and attach the Crystal Preview Window to that child.  In this way, Delphi's built-in support for MDI child windows is preserved.  Resizing of the Crystal Preview Window with the MDI Child is automatically handled inside the Crystal VCL.  The child form is freed when the MDI Child window is closed.

2. Programmer's may want more control over the appearance and behaviour of their MDI Child forms, above what is offered via option 1.  In that case, we recommend that you make the Parent and Child Forms in Delphi, attach the Crystal component to the Child Form, and set the WindowParent of the component to the Child Form.  To set the WindowParent property, simply pass it the name of the Form or Panel desired.  The resize event will have to be coded, so that the Crystal Preview Window resizes with the Child form:

procedure TChildForm1.OnResize(Sender: TObject);

begin

  SetWindowPos(Crpe1.ReportWindowHandle, HWND_TOP, 0, 0,

    ChildForm1.ClientWidth, ChildForm1.ClientHeight, SWP_NOZORDER);

end;

For a working example of option 2, see our MDI32 Sample Application.

Important Note!

When attaching the Crystal Preview window to another Form via the WindowParent property, be careful to make sure the Crystal Window is closed before the Form it is attached to is destroyed.  This will not be a problem if the VCL is attached to the Child Form, since it will be destroyed with the Child.  But if the VCL component is still in existence when the Child Form is destroyed, an Access Violation will occur when the VCL is finally freed, or possibly when the Print Job closes.  One way to avoid the error is to put a Crpe1.CloseWindow call in the Child Form's OnClose event:

procedure TChildForm1.OnClose(Sender: TObject; var Action: TCloseAction);

begin

  Crpe1.CloseWindow;

  Release;

end;


WindowParent property - See also
Related

DialogParent

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


WindowParent property - Example
Example

The code below makes the Crystal Preview Window a child of Form1:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.WindowState := wsNormal;

Crpe1.Output := toWindow;

Crpe1.WindowStyle.BorderStyle := bsNone;

{Attach Crystal Window to Parent Window}

Crpe1.WindowParent := Form1;

{Crystal Window Size Settings}

Crpe1.WindowSize.Top := 0;

Crpe1.WindowSize.Left := 0;

Crpe1.WindowSize.Height := Form1.Height - 30;

Crpe1.WindowSize.Width := Form1.Width - 8;

{Run the Report}

Crpe1.Execute;

{On Form Resize}

procedure TForm1.FormResize(Sender: TObject);

var

  WinHandle: hWnd;

begin

WinHandle := Crpe1.ReportWindowHandle;

SetWindowPos(WinHandle, HWND_TOP, 0, 0, Self.ClientWidth, Self.ClientHeight, SWP_NOZORDER);

end;


WindowState property

See also	Example

Declaration

property WindowState: TWindowState;

Type

TWindowState = (wsNormal, wsMinimized, wsMaximized);

Description

WindowState determines the state in which the Preview Window will appear.  This property is only applicable when Output is set to go toWindow.

•	WindowState is now an active property; setting it while the Crystal Preview Window is open will cause it to change the WindowState of the open window.

•	When the Crystal Preview Window is open, it is also possible to update the WindowState setting by calling RetrieveWindowState.


WindowState property - See also
Related

RetrieveWindowState

WindowButtonBar

WindowSize

WindowStyle

WindowZoom

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


WindowState property - Example
Example

Sets the Preview Window state to minimized:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.WindowState := wsMinimized;

Crpe1.Execute;


FieldMapping property

See also	Example

Declaration

property FieldMapping: TCrFieldMappingType;

Type

TCrFieldMappingType = (fmAuto, fmPrompt, fmEvent);

Description

FieldMapping can be used to provide a way to remap database field names in a Report if the field names have changed since the Report was designed.  If the field names stored in the Report no longer match the physical database table field names, the fields in the Report are considered to be "unmapped".  The FieldMapping setting is used in the VerifyDatabase method to determine how unmapped fields will be handled.

VerifyDatabase will cause the Print Engine to do one of three things, depending on the setting of the FieldMapping property:

1. FieldMapping set to fmAuto

Any fields in the Report that no longer have the same field names will be removed from the Report.

2. FieldMapping set to fmPrompt

If any field names have changed, the Print Engine will show a Mapping Dialog that can be used to map the fields to fields from the current database table.

3. FieldMapping set to fmEvent

If any field names have changed, an OnFieldMapping event will be triggered.  This event is on the events page of the Object Inspector, and allows the developer to either design their own Mapping Dialog, or bypass the dialog by doing the mapping in code.

Note

FieldMapping is only available in SCR 7 or higher.

The actual sequence of calls made to invoke FieldMapping should follow this order:

•	Set the ReportName property.

•	Set any LogOn Information (if using ODBC or SQL tables) via either Connect, LogOnInfo, or LogOnServer.

•	Set any new Table location information via the Tables object.

•	Set the FieldMapping property.

•	Call VerifyDatabase.

Alternatively, if VerifyDatabase is not called directly in code, it will automatically run when Crpe1.Execute is called.


FieldMapping property - See also
Related

OnFieldMapping

RetrieveFieldMapping

SendFieldMapping

VerifyDatabase

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


FieldMapping property - Example
Example

If the database structure or field names have changed, the following code will bring up Crystal's built-in Field Mapping dialog:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.FieldMapping := fmPrompt;

Crpe1.VerifyDatabase;


WindowEvents property

See also	Example

Declaration

property WindowEvents: boolean;

Description

The WindowEvents property activates the Preview Window callback events.  These callback events allow Delphi to respond to actions that take place on the Crystal Reports Preview Window, such as button clicks and drill-down events.  The various events listed on the Events page of the Object Inspector, and are prefixed with "w":

wOnActivateWindow

wOnCancelBtnClick

wOnCloseBtnClick

wOnCloseWindow

wOnDeActivateWindow

wOnDrillDetail

wOnDrillGroup

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnReadingRecords

wOnRefreshBtnClick

wOnMouseClick

wOnSearchBtnClick

wOnShowGroup

wOnStartEvent

wOnStopEvent

wOnZoomLevelChange

The WindowEvents property should be set before Execute is called.

Note

WindowEvents are only available with SCR 6 or higher.


WindowEvents property - See also
Related

WindowCursor

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


WindowEvents property - Example
Example

This code activates the Preview Window callback events:

Crpe1.ReportName := 'Report1.rpt';

Crpe1.Output := toWindow;

Crpe1.WindowEvents := True;

Crpe1.Execute;


ConnectMethod property

See also	Example

Declaration

property ConnectMethod: TCrConnectMethod;

Type

TCrConnectMethod = (useConnect, useLogOnInfo);

Description

The ConnectMethod property is used to tell the VCL which connection method will be used to set the log on information for Reports using SQL tables or ODBC datasources that require passwords.  There are two classes in the VCL that can set this information: Connect and LogOnInfo.  Trying to determine which one was to be used when the VCL ran a Report was not always easy, so the ConnectMethod property was created to make this more clear.

By default, ConnectMethod is set to useConnect.

Note

This property applies to the whole Report, including Subreports.  Therefore, it is not possible, for example, to use Connect on the main Report and LogOnInfo on the Subreport.  If ConnectMethod is set to useConnect, the Connect class will be used for the main Report and any Subreports.  If ConnectMethod is set to useLogOnInfo, the LogOnInfo class will be used for the main Report and any Subreports.


ConnectMethod property - See also
Related

Connect

LogOnInfo

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ConnectMethod property - Example
Example

This code sets the ConnectMethod to useConnect, then fills in the Connect Password property:

Crpe1.ReportName := 'C:\Company.rpt';

{Set the ConnectMethod}

Crpe1.ConnectMethod := useConnect;

{Retrieve the Connect information from the Report}

Crpe1.Connect.Retrieve;

{Set the Connect Password}

Crpe1.Connect.Password := '007';

{Propagate the Connect property values to any Subreports}

Crpe1.Connect.Propagate := True;

Crpe1.Output := toWindow;

Crpe1.Execute;

This code sets the ConnectMethod to useLogOnInfo, then fills in the LogOnInfo Password property:

var

  cnt : integer;

begin

Crpe1.ReportName := 'c:\Company.rpt';

{Set the ConnectMethod}

Crpe1.ConnectMethod := useLogOnInfo;

{Retrieve the LogOnInfo information from the Report}

Crpe1.LogOnInfo.Retrieve;

{Set the LogOnInfo Password for all tables}

for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do

  Crpe1.LogOnInfo[cnt].Password := '007';

Crpe1.Output := toWindow;

Crpe1.Execute;

end;


Log property

See also	Example

Declaration

property Log: TCrpeLog;

Type

TCrpeLog = class(TComponent)

Description

The Log property is not active at this time.  It's intent is to hook into a Log component for logging the Crystal VCL calls, but the Log component is not finished yet.  Do not use this property.


Log property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Log property - Example
Example

The Log property is not active.

Crpe1.ReportName := 'C:\Company.rpt';


CrpePath property

See also	Example

Declaration

property CrpePath: string;

Description

The CrpePath property can be used to set the directory that the CRPE32.DLL (Crystal Reports Print Engine) will be loaded from.  This is useful if there are different versions of CRPE32.DLL residing on the same system (perhaps for older or newer applications).  If this property is left blank, the VCL will rely on the Windows LoadLibrary function to search the standard Windows path.  According to the Win32 Help file the search order is:

1. The directory from which the application loaded.

2. The current directory.

3. Windows 95: The Windows system directory. Use the GetSystemDirectory function to get the path of this directory.

Windows NT: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32.

4. Windows NT: The 16-bit Windows system directory. There is no Win32 function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM.

5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.

6. The directories that are listed in the PATH environment variable.

Important Note

After the CRPE32.DLL loads, it in turn will attempt to load any custom Crystal Formula function DLL's and Export DLL's.

The Formula function DLL's are also refered to as UFL's, or User Function Libraries, and normally have the file prefix: U2L (or UFL for 16-bit).

The Export DLL's have the file prefix: U2F or U2D (UXF and UXD in 16-bit).

The CRPE will always search for these DLL's in the Windows\Crystal directory first (if it exists), and then follow the WinAPI search order outlined above.  This behaviour is built into CRPE and cannot be changed.  Therefore, even if you distribute all your Export and Formula DLL's in the same directory as CRPE, if there are older DLL's in a Windows\Crystal directory, these will be picked up instead.  If you attempt to avoid this problem by manually doing a LoadLibrary on each Export and Formula DLL, then CRPE will go ahead and load the ones in Windows\Crystal anyway, and you'll end up with two copies in memory!

If you are faced with this problem, the best way to deal with it is to make sure that there is no Windows\Crystal (or WinNT\Crystal) directory on the computer.  If there is, you can simply move all the files that it contains into the Windows or Windows\System directory, or somewhere else on the path.  In that way, when CRPE attempts to load them, it will not find them in Windows\Crystal and will then search it's own directory, where the ones you want it to find are located.


CrpePath property - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CrpePath property - Example
Example

Sets the CrpePath so that CRPE32.DLL will be loaded from a specific directory:

Crpe1.ReportName := 'C:\ReportApp\Company.rpt';

Crpe1.CrpePath := 'C:\ReportApp';

Crpe1.Output := toWindow;

Crpe1.WindowState := wsMinimized;

Crpe1.Execute;


Create method

See also	Example

Declaration

constructor Create(AOwner: TComponent); override;

Description

The Create method is called when the Crystal component is created.

•	If the component is attached to a Form, the Create method is called automatically when the Form is created.

•	If the component is being created dynamically, then the Create method must be called in code (see Example).


Create method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Create method - Example
Example

The following code illustrates how to create the Crystal component dynamically:

uses Ucrpe32;

procedure RunReport;

var

  Crpe1: TCrpe;

begin

  {Create the Crpe instance}

  Crpe1 := TCrpe.Create(Self);

  {Set the ReportName}

  Crpe1.ReportName := 'C:\Company.rpt';

  {Run the Report}

  Crpe1.Execute;

  {Go into a loop until the window is closed}

  while Crpe1.ReportWindowHandle <> 0 do

    Application.ProcessMessages;

  {Remove the Crpe instance from memory}

  Crpe1.Free;

end;


Destroy method

See also

Declaration

destructor Destroy; override;

Description

The Destroy method frees the Crystal component.  It is used internally in the VCL component and should not be called outside of the component.  If you are creating the component dynamically at runtime, use the Free method to release the component from memory.


Destroy method - See also
Related

Create

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Execute method

See also	Example

Declaration

function Execute: Boolean;

Description

The Execute method starts running the Report.  Internally it runs through a number of steps:

1.	Checks to see if it is being called from OnExecuteBegin, OnExecuteDoneSend, OnExecuteEnd, OnPrintEnded, OnWindowClose events.  If so, it exits since you cannot call Execute from an event inside the Execute method.

2.	If Output is set to go toExport, and the Export property, PromptOnOverwrite, is set to True, we check to see if the Export FileName exists.  If it does, throw up a warning dialog.

3.	Make sure the Print Job is open.

4.	Store the current Report number (in case we are on a Subreport), so we can restore it when finished.

5.	Check to see if the Subreports SubExecute property is True.  If we are currently on a Subreport, and SubExecute is True, the Subreport will be run.  Otherwise, the main Report will be run.

6.	Do the OnExecuteBegin event (if there is one).

7.	If SendOnExecute is True, loop through the Subreports, starting from highest number down to main Report and make the following calls (if SubExecute is True, we only loop once, making the calls to the current Subreport):

SendDiscardSavedData;

{Sends either Connect or LogOnInfo}

Tables.Send;

SessionInfo.Send;

SQL.FParams.Send;

ParamFields.Send;

SQL.Expressions.Send;

SQL.Send;  {SQL Query}

{if FieldMapping is not fmAuto, do VerifyDatabase}

Formulas.Send;

SortFields.Send;

GroupSortFields.Send;

GroupCondition.Send;

GroupOptions.Send;

Selection.Send;

GroupSelection.Send;

SectionHeight.Send;

SectionFont.Send;

SectionFormat.Send;

SectionFormatFormulas.Send;

AreaFormat.Send;

AreaFormatFormulas.Send;

GraphType.Send;

GraphText.Send;

GraphOptions.Send;

GraphData.Send;

PrintDate.Send;

Margins.Send;

SendDetailCopies;

{These properties are set only once: either for the Main Report,

 or for the Subreport if SubExecute is True}

SummaryInfo.Send;

ReportOptions.Send;

PrintOptions.Send;

Printer.Send;

SendProgressDialog;

SendDialogParent;

if (Output = toWindow) then

begin

  WindowButtonBar.Send;

  WindowCursor.Send

end;

SendOutput;

SendReportTitle;

8.	Do the OnExecuteDoneSend Event, if there is one.

9.	Set up the WindowEvents callback function for any assigned Window Events.

10.	Run the Report.

11.	If the Output is set to go toWindow, send in the WindowZoom settings:

if (Output = toWindow) then

  WindowZoom.Send;

12.	Check the OnExecuteEnd event, if there is one.

13.	Check the OnWindowClose event, if there is one.

14.	Check the OnPrintEnded event, if there is one.

15.	Restore the internal pointer to the current Subreport.


Execute method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Execute method - Example
Example

The following code illustrates a simple use of the Execute method to run a Report to Window:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;


Focused method

See also	Example

Declaration

function Focused: boolean;

Description

Determines if the Crystal Preview window has focus or not (ie. is it the uppermost window on the screen, the one that receives keyboard and mouse input).  This method can be used in concert with the SetFocus method.


Focused method - See also
Related

SetFocus

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Focused method - Example
Example

This code example checks to see if the Crystal Preview Window is the topmost window.  If not, it makes it the topmost:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

if not Crpe1.Focused then

  Crpe1.SetFocus;


OpenJob method

See also	Example

Declaration

function OpenJob: boolean;

Description

The PrintJob is automatically opened as required by the Crystal component.  If you want to force the Job to open at an earlier time, such as right after the ReportName is assigned, it can be done through this method.

What do you mean by "Open the PrintJob"?

What this means is that the Crystal Reports Print Engine DLL loads the Report file into memory.  Initially when the ReportName property of the Crystal component is assigned a value, space is allocated internally in the component, but the Print Engine does not yet need to load the Report, so the Print Job is not opened.  As soon as one of the Retrieve methods, or the Execute method is called, then the Print Engine loads the Report, and processes it accordingly.

In the case of a Retrieve call, the Print Engine passes the desired values back to the Crystal component.  In the case of an Execute call, the Crystal component values are passed to the Print Engine, and then the Print Engine runs the Report with those new values.


OpenJob method - See also
Related

CloseJob

CancelJob

OpenEngine

CloseEngine

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OpenJob method - Example
Example

The OpenJob method is used to force the PrintJob open after the ReportName is set.  Otherwise, OpenJob would occur automatically when Execute is called, or any of the Retreive methods:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.OpenJob;

Crpe1.Output := toWindow;

Crpe1.Execute;


ReportWindowHandle method

See also	Example

Declaration

function ReportWindowHandle: integer;

Description

The ReportWindowHandle property returns the current Window Handle number of an open Preview Window.  It is useful for determining when the window is closed.  For this purpose, the OnWindowClose event can also be used.


ReportWindowHandle method - See also
Related

OnWindowClose

WindowParent

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ReportWindowHandle method - Example
Example

The following example checks the ReportWindowHandle property to see when the Preview Window is closed.  When the window is closed, the application Form closes also:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

while Crpe1.ReportWindowHandle > 0 do

  Application.ProcessMessages;

Close;


RetrieveDetailCopies method

See also	Example

Declaration

function RetrieveDetailCopies: boolean;

Description

RetrieveDetailCopies returns the number of Detail Copies specified in the currently open Report, and populates the DetailCopies property with the value.  This call can also be made to a Subreport.


RetrieveDetailCopies method - See also
Related

DetailCopies

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


RetrieveDetailCopies method - Example
Example

The following example retrieves the Detail Copies from a Report:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.RetrieveDetailCopies;

ShowMessage(IntToStr(Crpe1.DetailCopies));


RetrieveReportTitle method

See also	Example

Declaration

function RetrieveReportTitle: boolean;

Description

RetrieveReportTitle returns the Report Title from the currently open Report, and populates the ReportTitle property with the value.  This call can also be made to a Subreport.


RetrieveReportTitle method - See also
Related

ReportTitle

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


RetrieveReportTitle method - Example
Example

The following example retrieves the Report Title from a Report:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.RetrieveReportTitle;

ShowMessage(Crpe1.ReportTitle);


CancelJob method

See also	Example

Declaration

procedure CancelJob;

Description

CancelJob can be used to stop the processing of a Report.  It can be called after the Execute method has been called.  Normally the CancelJob method would be associated with a button click, or some other user event, therefore it is particularly useful when building a custom button bar to replace the standard Crystal Preview Window button bar.

See also: Creating a Custom Button Bar.


CancelJob method - See also
Related

CloseJob

OpenJob

WindowButtonBar

Creating a Custom Button Bar

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CancelJob method - Example
Example

The following code cancels the running of the Report right after Execute.  Normally the CancelJob call would be associated with a button click, or some other user event:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Execute;

Crpe1.CancelJob;


Clear method

See also	Example

Declaration

procedure Clear;

Description

The Clear method for the Crystal component invokes the following Sub-class Clear methods for the main Report as well as any subreports:

  AreaFormat.Clear;

  AreaFormatFormulas.Clear;

  Connect.Clear;

  Formulas.Clear;

  GraphData.Clear;

  GraphOptions.Clear;

  GraphText.Clear;

  GraphType.Clear;

  GroupCondition.Clear;

  GroupOptions.Clear;

  GroupSelection.Clear;

  GroupSortFields.Clear;

  LogOnInfo.Clear;

  Margins.Clear;

  ParamFields.Clear;

  PrintDate.Clear;

  SectionFont.Clear;

  SectionFormat.Clear;

  SectionFormatFormulas.Clear;

  SectionHeight.Clear;

  Selection.Clear;

  SessionInfo.Clear;

  SortFields.Clear;

  SQL.Clear;

  SQL.Params.Clear;

  SQL.Expressions.Clear;

  Tables.Clear;

  DetailCopies := TCRPE_DEFAULT_DETAILCOPIES;

  FieldMapping := fmAuto;

  ReportTitle := '';

It then clears the following component Sub-class objects:

  Export.Clear;

  LogOnServer.Clear;

  Printer.Clear;

  PrintOptions.Clear;

  ReportOptions.Clear;

  Subreports.Clear;

  SummaryInfo.Clear;

  WindowButtonBar.Clear;

  WindowCursor.Clear;

  WindowSize.Clear;

  WindowStyle.Clear;

  WindowZoom.Clear;

It also sets the following properties to default:

  CanCloseEngine := True;

  DiscardSavedData := False;

  HasSavedData := False;

  IsJobFinished := True;

  Output := toWindow;

  ProgressDialog := True;

  ReportName := '';

  SendOnExecute := True;

  WindowEvents := False;

  WindowState := wsNormal;

Finally, it also de-allocates any memory associated with the above classes, and then closes the PrintJob.  There are some alternatives if the programmer does not want to clear all of these properties:

1. To clear just the Subreport structures, while leaving the main Report information intact, use Subreports.Clear.

2. To clear the Subreport and main Report structures, while leaving the Window, Printer, and Export related classes as they are, use CloseJob.

When a new Report is assigned to the ReportName property, a CloseJob call is invoked, not a Clear.  Thus the Window, Printer, and Export related settings are preserved.  The only time the Clear method is called internally in the component is when it is destroyed.  However, if it is desired to have all the settings of the component returned to default, the Clear method can be called before setting a new ReportName.


Clear method - See also
Related

CloseJob

ReportName

Subreports.Clear

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Clear method - Example
Example

The following example loads a Report and runs it.  When the Report has finished, the Crystal component is cleared to set everything back to default, and another Report is loaded:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toPrinter;

Crpe1.Execute;

while not Crpe1.PrintEnded do

  Application.ProcessMessages;

Crpe1.Clear;

Crpe1.ReportName := 'C:\NewReport.rpt';


CloseEngine method

See also	Example

Declaration

procedure CloseEngine;

Description

CloseEngine causes any open Print Job to be closed, and then closes the Crystal Reports Print Engine DLL, and removes it from memory.  It usually happens automatically when the component is destroyed, or the Form on which the component is attached is destroyed, but can also be called in code if desired.


CloseEngine method - See also
Related

OpenJob

CloseJob

OpenEngine

CanCloseEngine

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CloseEngine method - Example
Example

The following example uses the CloseEngine method to unload the CRPE32.DLL after running a Report:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toPrinter;

Crpe1.Execute;

while not Crpe1.PrintEnded do

  Application.ProcessMessages;

if Crpe1.CanCloseEngine then

  Crpe1.CloseEngine;


CloseJob method

See also	Example

Declaration

procedure CloseJob;

Description

CloseJob closes the currently open Report in the Print Engine, and clears any memory allocated for it in the Crystal component.  This will not close a currently open Preview Window, but no further calls can be made from the component to the window.  If you want to close the Window, see the CloseWindow method.

CloseJob automatically takes place when the ReportName property is assigned a different Report name, or when the Crystal component is destroyed, but can also be called in code if desired.


CloseJob method - See also
Related

OpenJob

CancelJob

OpenEngine

CloseEngine

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CloseJob method - Example
Example

The following example uses the CloseJob method to close the Print Job after running a Report:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toPrinter;

Crpe1.Execute;

while not Crpe1.PrintEnded do

  Application.ProcessMessages;

Crpe1.CloseJob;


CloseWindow method

See also	Example

Declaration

procedure CloseWindow;

Description

The CloseWindow method closes an open Preview Window.  It does not Close the PrintJob, nor does it clear the component.  If you are customizing Preview Window controls, implement this method to allow the user to close the Preview Window when finished viewing the Report.

Although it is possible to open up more than one Preview Window for the same PrintJob, the VCL can only access the last one opened, hence CloseWindow will only work on the last window opened.  If you need to close more than one open Preview Window, consider storing the Window Handles to variables and using the Windows API call "CloseWindow" to close these.

See also: Creating a Custom Button Bar.


CloseWindow method - See also
Related

ShowWindow

HideWindow

ExportWindow

PrintWindow

WindowButtonBar

Creating a Custom Button Bar

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CloseWindow method - Example
Example

The following example runs a Report to Window.  When a button on the application is pressed, the Window is closed:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

{When a close button is pressed do...}

if Crpe1.ReportWindowHandle > 0 then

  Crpe1.CloseWindow;


ExportWindow method

See also	Example

Declaration

procedure ExportWindow(const bMail: Boolean);

Description

The ExportWindow procedure sends the Report that is displayed in the current Preview Window to an Export destination.  This procedure will not use the Export settings of the component, but will instead prompt the user for the Export Options (FileType, FileName, etc.), in the same way as when the Export button on the Crystal Button Bar is clicked.

The "bMail" boolean determines if the first prompt will come up defaulted to Email as the Destination:

•	If bMail is True, Email will come up as default.

•	If bMail is False, Diskfile will appear as the default.

This method is particularly useful when building a custom button bar to simulate the Export Button that appears on the Preview Window button bar.

See also: Creating a Custom Button Bar.


ExportWindow method - See also
Related

CloseWindow

PrintWindow

WindowButtonBar

Creating a Custom Button Bar.

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ExportWindow method - Example
Example

The following example runs a Report to Window.  When a button on the application is pressed, the Window is exported:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

{When an Export button is pressed do...}

Crpe1.ExportWindow;


LogOnPrivateInfo method

See also	Example

Declaration

function LogOnPrivateInfo(DllName: string; PrivateInfo: pointer): boolean;

Description

LogOnPrivateInfo can be used to "piggyback" the Crystal Reports database connection on your application's existing connection to a Server.  If you are already logged on, this function lowers the number of connections established by a workstation, thus reducing application time and network traffic.  It also prevents a Crystal Reports Log Off call from disconnecting an application's existing connection to the Server.  Note that this call only works with ODBC connections.

Parameter	Description

DllName	Currently, this can only be 'PDSODBC.DLL'.  Even though 32-bit Crystal actually uses the P2SODBC.DLL, we use PDSODBC.DLL to refer to either, in this call.

PrivateInfo	In the application, a connection to the server has to have been established and this in turn generates a Handle to a Database Connection (HDBC).  This parameter specifies the application's handle to the connection.  This makes Seagate Crystal Reports aware of the existing connection so it can use it instead of establishing a new one.  Since the reports with which this function works are based on ODBC, this parameter is actually an ODBC HDBC.

The LogOnPrivateInfo call returns True if the call is successful; False if the call fails.

Note

At the time of this writing, the return value is always True.  This is not a fault of the Crystal component, but rather the Print Engine.  It will hopefully be fixed in a future release of the Print Engine DLL.

Remarks

This function can only be used with database connections established by ODBC or Q+E Library 2.0.  Any other database connections can not be accessed by this function.

If the application uses the Q+E Library to connect, get the ODBC HDBC by using the following function calls:

qeConnect 	- Opens a connection to the server.

qeGetODBCHdbc	- Returns the ODBC hdbc.

See the Intersolv DataDirect Developer's Toolkit for more information.

If the application uses ODBC to connect, get the ODBC HDBC by using the following function calls:

SQLAllocEnv 	- Initializes the ODBC call level interface and allocates memory for an environment handle.

SQLAllocConnect	- Returns an ODBC HDBC.

See the ODBC SDK documentation for more information.


LogOnPrivateInfo method - See also
Related

ODBC32.PAS

Connect

LogOnInfo

LogOnServer

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


LogOnPrivateInfo method - Example
Example

The following code samples show how to prompt for an ODBC datasource, connect to it, and then piggyback the Report on that connection.  Note that the database connection used in the Report must be based off the same datasource as the LogOnPrivateInfo call is connecting to:

uses

  ODBC32;

implementation

{$R *.DFM}

var

  henv : Pointer;

  hdbc : Pointer;

  hstmt : Pointer;

procedure TForm1.Connect;

var

  ConIn, ConOut : MyUChar;

  LenIn, LenOut : smallint;

  RetCode : smallint;

  TotOut : Pointer;

  x, I : integer;

  Flag : BOOL;

  TempStr : string;

  Temp, Temp2 : PChar;

begin

  Flag:= False;

  LenIn := 256;

  LenOut := 256;

  henv := nil;

  hdbc := nil;

  hstmt := nil;

  RetCode := SQLAllocEnv(henv);

  if Retcode <> SQL_SUCCESS then

    ShowMessage('SQLAllocEnv Failed');

  RetCode := SQLAllocConnect(henv, hdbc);

  if Retcode <> SQL_SUCCESS then

    ShowMessage('SQLAllocConnect Failed');

  FillChar(ConIn, 256, ' ');

  RetCode := SQLDriverConnect(hdbc, Form1.Handle, ConIn, LenIn, ConOut, LenOut, TotOut, SQL_DRIVER_PROMPT);

  if ((Retcode <> SQL_SUCCESS) and (Retcode <> SQL_SUCCESS_WITH_INFO)) then

  begin

    ShowMessage('SQLDriverConnect Failed');

    Flag := True

  end

  else

  begin

    ShowMessage('SQLDriverConnect Successful');

    EdtConnection.Text := StrPas(ConOut);

    if RetCode = SQL_SUCCESS_WITH_INFO then

  end;

  RetCode := SQLAllocStmt(hdbc, hstmt);

  if Retcode <> SQL_SUCCESS then

    ShowMessage('SQLAllocStmt Failed');

end;

procedure TForm1.Disconnect;

var

  RetCode : ShortInt;

begin

  Crpe1.CloseJob;

  RetCode := SQLFreeStmt(hstmt, SQL_CLOSE);

  if Retcode <> SQL_SUCCESS then

    ShowMessage('SQLFreeStmt Failed');

  RetCode := SQLDisconnect(hdbc);

  if Retcode <> SQL_SUCCESS then

    ShowMessage('SQLDisconnect Failed');

  RetCode := SQLFreeConnect(hdbc);

  if Retcode <> SQL_SUCCESS then

    ShowMessage('SQLFreeConnect Failed');

  RetCode := SQLFreeEnv(henv);

  if Retcode <> SQL_SUCCESS then

    ShowMessage('SQLFreeEnv Failed');

end;

procedure TForm1.RunReport;

begin

  Crpe1.ReportName := 'C:\Company.rpt';

  Crpe1.Output := toWindow;

  Crpe1.OpenJob;

  if not Crpe1.LogOnServerPrivateInfo('PDSODBC.DLL', hdbc) then

  begin

    ShowMessage('LogOnServerPrivateInfo Failed');

    Exit;

  end;

  Crpe1.Execute;

end;


ODBC32.PAS

{This is a Delphi header file for the 32-bit ODBC DLL.}

{It is useful for the LogOnPrivateInfo method.}

unit Odbc32;

{$X+}

interface

uses

  Windows;

const

   SQL_INVALID_HANDLE            = -2;

   SQL_ERROR                     = -1;

   SQL_SUCCESS                   =  0;

   SQL_SUCCESS_WITH_INFO         =  1;

   SQL_NO_DATA_FOUND             = 100;

   SQL_DRIVER_NOPROMPT           = 0;

   SQL_DRIVER_COMPLETE           = 1;

   SQL_DRIVER_PROMPT             = 2;

   SQL_DRIVER_COMPLETE_REQUIRED  = 3;

   SQL_CLOSE                     = 0;

   SQL_C_CHAR                    = 1;

   SQL_DRIVER_NAME               = 6;

   SQL_DRIVER_VER                = 7;

   SQL_DBMS_NAME                 = 17;

   SQL_DBMS_VER                  = 18;

   SQL_DRIVER_ODBC_VER           = 77;

   SQL_ODBC_VER                  = 10;

   SQL_TXN_ISOLATION_OPTION      = 72;

   SQL_TXN_READ_UNCOMMITTED      = 1;

Type

   MyUChar = Array[0..255] of char;

   MyState = Array[0..15] of Char;

   function SQLAllocEnv(var henv : Pointer) : SmallInt StdCall;

   function SQLAllocConnect(henv : Pointer;

                        var hdbc : Pointer) : SmallInt StdCall;

   function SQLDriverConnect(hdbc : Pointer;

                           window : hWnd;

                      szConnStrIn : MyUChar;

                      cbConnStrIn : SmallInt;

                     szConnStrOut : MyUChar;

                  cbConnStrOutMax : SmallInt;

                var pcbConnStrOut : Pointer;

                fDriverCompletion : Word ) : SmallInt StdCall;

   function SQLAllocStmt(hdbc : Pointer;

                   var phstmt : Pointer) : SmallInt StdCall;

   function SQLError(henv : Pointer;

                     hdbc : Pointer;

                    hstmt : Pointer;

               szSqlState : PChar;

        var pfNativeError : LongInt;

               szErrorMsg : PChar;

            cbErrorMsgMax : SmallInt;

          var pcbErrorMsg : SmallInt) : SmallInt StdCall;

   function SQLGetInfo(hdbc : Pointer;

                  fInfoType : SmallInt;

               rgbInfoValue : PChar;

             cbInfoValueMax : SmallInt;

           var pcbInfoValue : SmallInt) : SmallInt StdCall;

   function SQLSetConnectOption(hdbc : Pointer;

                             fOption : Word;

                              vParam : Pointer) : SmallInt StdCall;

   function SQLTables(hstmt : Pointer;

                   Database : PChar;

                DatabaseLen : SmallInt;

                  DataOwner : PChar;

                   OwnerLen : SmallInt;

                      Table : PChar;

                   TableLen : SmallInt;

                  TableType : PChar;

               TableTypeLen : SmallInt) : SmallInt StdCall;

   function SQLColumns(hstmt : Pointer;

            szTableQualifier : PChar;

            cbTableQualifier : SmallInt;

                szTableOwner : PChar;

                cbTableOwner : SmallInt;

                 szTableName : PChar;

                 cbTableName : SmallInt;

                szColumnName : PChar;

                cbColumnName : SmallInt) : SmallInt StdCall;

   function SQLProcedures(hstmt : Pointer;

                szProcQualifier : PChar;

                cbProcQualifier : SmallInt;

                    szProcOwner : PChar;

                    cbProcOwner : SmallInt;

                     szProcName : PChar;

                     cbProcName : SmallInt) : SmallInt StdCall;

   function SQLProcedureColumns(hstmt : Pointer;

                      szProcQualifier : PChar;

                      cbProcQualifier : SmallInt;

                          szProcOwner : PChar;

                          cbProcOwner : SmallInt;

                           szProcName : PChar;

                           cbProcName : SmallInt;

                         szColumnName : PChar;

                         cbColumnName : SmallInt) : SmallInt StdCall;

   function SQLExecDirect(hstmt : Pointer;

                       szSqlStr : PChar;

                       cbSqlStr : LongInt) : SmallInt StdCall;

   function SQLExecute(hstmt : Pointer) : SmallInt StdCall;

   function SQLPrepare(hstmt : Pointer;

                    szSqlStr : PChar;

                    cbSqlStr : LongInt) : SmallInt StdCall;

   function SQLNumResultCols(hstmt : Pointer;

                         var pccol : SmallInt) : SmallInt StdCall;

   function SQLDescribeCol(hstmt : Pointer;

                            icol : Word;

                       szColName : PChar;

                    cbColNameMax : SmallInt;

                  var pcbColName : SmallInt;

                   var pfSqlType : SmallInt;

                   var pcbColDef : LongInt;

                    var pibScale : SmallInt;

                  var pfNullable : SmallInt) : SmallInt StdCall;

   function SQLFetch(hstmt : Pointer) : SmallInt StdCall;

   function SQLGetData(hstmt : Pointer;

                        icol : Word;

                      fCType : SmallInt;

                    rgbValue : PChar;

                  cbValueMax : LongInt;

                var pcbValue : LongInt) : SmallInt StdCall;

   function SQLFreeStmt(hstmt : Pointer;

                      fOption : Word ) : SmallInt StdCall;

   function SQLDisconnect(hdbc : Pointer) : SmallInt StdCall;

   function SQLFreeConnect(hdbc : Pointer) : SmallInt StdCall;

   function SQLFreeEnv(henv : Pointer) : SmallInt StdCall;

implementation

   function SqlAllocEnv;           external 'ODBC32.DLL';

   function SQLAllocConnect;       external 'ODBC32.DLL';

   function SQLDriverConnect;      external 'ODBC32.DLL';

   function SQLConnect;            external 'ODBC32.DLL';

   function SQLAllocStmt;          external 'ODBC32.DLL';

   function SQLFreeStmt;           external 'ODBC32.DLL';

   function SQLDisconnect;         external 'ODBC32.DLL';

   function SQLFreeConnect;        external 'ODBC32.DLL';

   function SQLFreeEnv;            external 'ODBC32.DLL';

   function SQLError;              external 'ODBC32.DLL';

   function SQLTables;             external 'ODBC32.DLL';

   function SQLFetch;              external 'ODBC32.DLL';

   function SQLGetData;            external 'ODBC32.DLL';

   function SQLColumns;            external 'ODBC32.DLL';

   function SQLProcedureColumns;   external 'ODBC32.DLL';

   function SQLProcedures;         external 'ODBC32.DLL';

   function SQLExecDirect;         external 'ODBC32.DLL';

   function SQLPrepare;            external 'ODBC32.DLL';

   function SQLNumResultCols;      external 'ODBC32.DLL';

   function SQLDescribeCol;        external 'ODBC32.DLL';

   function SQLGetInfo;            external 'ODBC32.DLL';

   function SQLExecute;            external 'ODBC32.DLL';

   function SQLSetConnectOption;   external 'ODBC32.DLL';

end.


OpenEngine method

See also	Example

Declaration

procedure OpenEngine;

Description

OpenEngine forces the Crystal Reports Print Engine DLL to be loaded into memory and opened for use.  It is called automatically within the Crystal component, but may be called in code if desired.


OpenEngine method - See also
Related

OpenJob

CloseJob

CloseEngine

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OpenEngine method - Example
Example

The following example uses the OpenEngine method to load the CRPE32.DLL (this is not normally necessary):

Crpe1.OpenEngine;

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toPrinter;

Crpe1.Execute;


PrintWindow method

See also	Example

Declaration

procedure PrintWindow;

Description

The PrintWindow procedure sends the Report that is displayed in the current Preview Window to printer.  It is particularly useful when building a custom button bar to simulate the Print Button that appears on the Preview Window button bar.

See also: Creating a Custom Button Bar.


PrintWindow method - See also
Related

CloseWindow

ExportWindow

WindowButtonBar

Creating a Custom Button Bar.

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


PrintWindow method - Example
Example

The following example runs a Report to Window.  When a button on the application is pressed, the Window is printed:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

{When an Print button is pressed do...}

Crpe1.PrintWindow;


SendDetailCopies method

See also	Example

Declaration

procedure SendDetailCopies;

Description

SendDetailCopies sends the value of the DetailCopies property to the Crystal Reports Print Engine.  This procedure is called automatically when the Execute method is called, provided that the SendOnExecute property is set to True.  It does not normally need to be called in code.

If SendOnExecute is set to False, then all of the information sent from the Crystal component to the Print Engine must be done manually.  This feature is provided for debugging purposes.   We recommend that you leave SendOnExecute to True.


SendDetailCopies method - See also
Related

DetailCopies

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SendDetailCopies method - Example
Example

In this example, the DetailCopies settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SendDetailCopies;


SendDiscardSavedData method

See also	Example

Declaration

procedure SendDiscardSavedData;

Description

SendDiscardSavedData sends the value of the DiscardSavedData property to the Crystal Reports Print Engine.  This procedure is called automatically when the Execute method is called, provided that the SendOnExecute property is set to True.  It does not normally need to be called in code.

If SendOnExecute is set to False, then all of the information sent from the Crystal component to the Print Engine must be done manually.  This feature is provided for debugging purposes.   We recommend that you leave SendOnExecute to True.


SendDiscardSavedData method - See also
Related

DiscardSavedData

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SendDiscardSavedData method - Example
Example

In this example, the DiscardSavedData settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SendDiscardSavedData;


SendOutput method

See also	Example

Declaration

procedure SendOutput;

Description

SendOutput sends the value of the Output property to the Crystal Reports Print Engine.  This procedure is called automatically when the Execute method is called, provided that the SendOnExecute property is set to True.  It does not normally need to be called in code.

If SendOnExecute is set to False, then all of the information sent from the Crystal component to the Print Engine must be done manually.  This feature is provided for debugging purposes.   We recommend that you leave SendOnExecute to True.


SendOutput method - See also
Related

Output

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SendOutput method - Example
Example

In this example, the Output settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SendOutput;


SendProgressDialog method

See also	Example

Declaration

procedure SendProgressDialog;

Description

SendProgressDialog sends the value of the ProgressDialog property to the Crystal Reports Print Engine.  This procedure is called automatically when the Execute method is called, provided that the SendOnExecute property is set to True.  It does not normally need to be called in code.

If SendOnExecute is set to False, then all of the information sent from the Crystal component to the Print Engine must be done manually.  This feature is provided for debugging purposes.   We recommend that you leave SendOnExecute to True.


SendProgressDialog method - See also
Related

ProgressDialog

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SendProgressDialog method - Example
Example

In this example, the ProgressDialog settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SendProgressDialog;


SendReportTitle method

See also	Example

Declaration

procedure SendReportTitle;

Description

SendReportTitle sends the value of the ReportTitle property to the Crystal Reports Print Engine.  This procedure is called automatically when the Execute method is called, provided that the SendOnExecute property is set to True.  It does not normally need to be called in code.

If SendOnExecute is set to False, then all of the information sent from the Crystal component to the Print Engine must be done manually.  This feature is provided for debugging purposes.   We recommend that you leave SendOnExecute to True.


SendReportTitle method - See also
Related

ReportTitle

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SendReportTitle method - Example
Example

In this example, the ReportTitle settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SendReportTitle;


SetFocus method

See also	Example

Declaration

procedure SetFocus;

Description

This procedure sets the focus of the Windows desktop to the Crystal Preview Window.  Therefore it should only be called after the Execute method, and can be used in concert with the Focused method.

Normally SetFocus does not need to be called, but if you find that your application Form keeps coming to the front after the Preview Window opens, then this call can be used to prevent that.


SetFocus method - See also
Related

Focused

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SetFocus method - Example
Example

This code example checks to see if the Crystal Preview Window is the topmost window.  If not, it makes it the topmost:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

if not Crpe1.Focused then

  Crpe1.SetFocus;


CopyFrom method

See also	Example

Declaration

procedure CopyFrom(Source: TCrpe);

Description

The CopyFrom method copies the Component values from another TCrpe object.  It is similar to Delphi's Assign method.  It is useful for transferring or temporary storage of values.


CopyFrom method - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


CopyFrom method - Example
Example

The following example copies all the Component values to a temporary TCrpe object:

var

tempCrpe : TCrpe;

begin

tempCrpe := TCrpe.Create;

tempCrpe.CopyFrom(Crpe1);

{...later, when finished with the temp object...}

tempCrpe.Free;

end;


RetrieveFieldMapping method

See also

Declaration

function RetrieveFieldMapping: boolean;

Description

This function returns the current FieldMapping setting from a Report, and updates the FieldMapping property accordingly.


RetrieveFieldMapping method - See also
Related

FieldMapping

OnFieldMapping

SendFieldMapping

VerifyDatabase

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SendFieldMapping method

See also

Declaration

function SendFieldMapping: boolean;

Description

The SendFieldMapping method sends the FieldMapping property settings to the Print Engine.  This method is called internally in the VCL whenever VerifyDatabase is called, therefore it should not be necessary to make this call directly.

Also, if FieldMapping is set to something other than "fmAuto", and VerifyDatabase is not called directly in code, VerifyDatabase will be automatically called in the Execute method of the main class (Crpe1.Execute).


SendFieldMapping method - See also
Related

FieldMapping

OnFieldMapping

RetrieveFieldMapping

VerifyDatabase

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


VerifyDatabase method

See also	Example

Declaration

function VerifyDatabase: boolean;

Description

This method requires Seagate Crystal Reports 7.0 or higher.  The VerifyDatabase method causes the Crystal Reports Print Engine to re-read the structure of the database tables used in a Report, and update the Report accordingly.  Since the Report stores the structure information for every table it uses, this should be updated if the structure (field names, sizes and types) has changed.

This method checks the FieldMapping setting, and if any of the field names have changed, it will cause the Print Engine to do one of three things, depending on the setting of the FieldMapping property:

1. FieldMapping set to fmAuto

Any fields in the Report that no longer have the same field names will be removed from the Report.

2. FieldMapping set to fmPrompt

If any field names have changed, the Print Engine will show a Mapping Dialog that can be used to map the fields to fields from the current database table.

3. FieldMapping set to fmEvent

If any field names have changed, an OnFieldMapping event will be triggered.  This event is on the events page of the Object Inspector, and allows the developer to either design their own Mapping Dialog, or bypass the dialog by doing the mapping in code.

Note

The actual sequence of calls made to invoke FieldMapping should follow this order:

•	Set the ReportName property.

•	Set any LogOn Information (if using ODBC or SQL tables) via either Connect, LogOnInfo, or LogOnServer.

•	Set any new Table location information via the Tables object.

•	Set the FieldMapping property.

•	Call VerifyDatabase.


VerifyDatabase method - See also
Related

FieldMapping

OnFieldMapping

RetrieveFieldMapping

SendFieldMapping

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


VerifyDatabase method - Example
Example

The following example sets the FieldMapping property and then calls VerifyDatabase.  If the Database has changed, a Field Mapping dialog will appear:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.FieldMapping := fmPrompt;

Crpe1.VerifyDatabase;


HideWindow method

See also	Example

Declaration

procedure HideWindow;

Description

The HideWindow method makes the Preview Window invisible.  Use ShowWindow to make it appear again.


HideWindow method - See also
Related

ShowWindow

CloseWindow

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


HideWindow method - Example
Example

The following example illustrates the HideWindow method:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.HideWindow;

{...after a while...}

Crpe1.ShowWindow;


RetrieveWindowState method

See also	Example

Declaration

procedure RetrieveWindowState;

Description

RetrieveWindowState retrieves the current state of the open Preview Window, and updates the WindowState property with this value.


RetrieveWindowState method - See also
Related

WindowState

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


RetrieveWindowState method - Example
Example

The following example uses the RetrieveWindowState call to obtain the state of the open Preview Window:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

{...after a while...}

Crpe1.RetrieveWindowState;


ShowWindow method

See also	Example

Declaration

procedure ShowWindow;

Description

The ShowWindow method makes a hidden Preview Window visible again.  Use HideWindow to make it invisible again.


ShowWindow method - See also
Related

HideWindow

CloseWindow

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


ShowWindow method - Example
Example

The following example illustrates the ShowWindow method:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.HideWindow;

{...after a while...}

Crpe1.ShowWindow;


SendDialogParent method

See also	Example

Declaration

procedure SendDialogParent;

Description

The SendDialogParent method sends the VCL's DialogParent property settings to the Crystal Reports Print Engine.  This is automatically called during the Execute method (provided that SendOnExecute is set to True), so does not normally need to be called in code.


SendDialogParent method - See also
Related

DialogParent

WindowParent

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


SendDialogParent method - Example
Example

In this example, the DialogParent settings are sent from the Crystal component to the Crystal Reports Print Engine DLL.  This is normally handled automatically in the Execute method:

Crpe1.SendDialogParent;


DiscardData method

See also	Example

Declaration

procedure DiscardData;

Description

A Report can be created with Saved Data.  This means that the data it was last run with is saved with the Report, and unless it is discarded, the Report will by default run with the Saved Data instead of reading the Database.  This is sometimes desirable, such as when a Report is being distributed to users who do not have access to the Database but would like to preview and print the Reports anyway.

In most other cases, applications that call Reports should make sure they discard the Saved Data.  Using the DiscardData method, or setting the DiscardSavedData property to True will do that.  The DiscardData method works immediately on the open Report, whereas the DiscardSavedData property only acts when Crpe1.Execute is called.

The HasSavedData property can be checked to see if the Report has Saved Data or not.

Note

If a Report is executed at runtime, and it is still the currently loaded Report in the VCL, running it again will cause it to use the Saved Data from the previous run.  Therefore, if running a Report more than once in a row, with different parameters, make sure and either call DiscardData or set DiscardSavedData to True between each run.


DiscardData method - See also
Related

DiscardSavedData

HasSavedData

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


DiscardData method - Example
Example

This code example calls the DiscardData method.  Any data saved with the Report, either when the Report was saved in Crystal Reports Designer, or because the Report was run once already, will be discarded immediately:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.DiscardData;

Crpe1.Output := toWindow;

Crpe1.Execute;


OnError event

See also	Example

Declaration

property OnError: TCrpeErrorEvent;

Type

TCrpeErrorEvent = procedure(Sender: TObject; const ErrorNum: smallint; const ErrorString: string; var IgnoreError: TCrBoolean) of object;

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The OnError event occurs in two instances:

1. When an error is returned from the Crystal Reports Print Engine.  The error can be related to the functioning of the Print Engine, but more often it is related to invalid values passed in.

2. When an error is generated within the component's internal code.  This can be caused by problems allocating memory, values being passed that are invalid, specifying subscripts that are out-of-range, etc.

There are three ways in which an Error will be handled:

1. There is no OnError Event defined, or the IgnoreError flag is left at cDefault.  In this case, the built-in Exception will be raised, showing the default Error Dialog, with the Error Number and Error String.

2. An OnError Event is defined, but the IgnoreError flag is set to cFalse.  In this case, the VCL will raise a silent Abort exception, but no Error dialog will be shown.

3. An OnError Event is defined, and the IgnoreError flag is set to cTrue.  In this case, the VCL will assume that the Error has been handled in the OnError event, and will proceed program execution, either continuing to the next iteration of a loop, or continuing to the next procedure (if there are any more to be run).  Care must be taken in suppressing errors which would otherwise indicate a problem.

•	The ErrorNum parameter passed in the OnEngineError event contains the number of the current Error, and the ErrorString parameter contains the Print Engine description of the current Error.  These are also available via the LastErrorNumber and LastErrorString properties.

•	The OnError event allows the programmer to handle the errors raised in a way that will suit the interface of the application.  For example, a custom dialog could be built to display the ErrorString instead of the built-in one.

For a complete list of possible Errors: Error Numbers & Strings.


OnError event - See also
Related

Error Numbers & Strings

LastErrorNumber

LastErrorString

PrintEngineErrorMessages

Other Events

OnJobOpened

OnExecuteBegin

OnExecuteDoneSend

OnExecuteEnd

OnPrintEnded

OnWindowClose

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnError event - Example
Example

This procedure which is placed in the OnError event, causes a user-defined Dialog to appear with two buttons, one for Cancel, and one for Continue (ignore the error).  If Continue is pressed, the IgnoreError flag is set to cTrue:

procedure TForm1.Crpe1Error(const ErrorNum: Smallint; const ErrorString: string; var IgnoreError: TCrBoolean);

begin

  dlgError := TdlgError.Create(Application);

  {Dialog Title}

  if ErrorNum < 500 then

    dlgError.lblTitle.Caption := 'Crystal Reports Component Error'

  else

    dlgError.lblTitle.Caption := 'Crystal Reports Engine Error';

  {Error Number}

  if ErrorNum > 0 then

    dlgError.lblErrorNumber.Caption := 'Error #: ' + IntToStr(ErrorNum)

  else

    dlgError.lblErrorNumber.Caption := 'Error Number Undefined';

  {Error String}

  dlgError.lblErrorString.Caption := ErrorString;

  {Show Dialog}

  dlgError.ShowModal;

  if dlgError.ModalResult = mrOk then

    IgnoreError := cTrue;

end;


Error Numbers & Strings

Crystal Component Errors	Crystal Reports Print Engine Errors

Crystal Component Errors

The Crystal Component generates the following errors when necessary:

General

100	Error loading library: CRPE32.DLL

101	CRPE32.DLL is not loaded

102	Incompatible CRPE version: requires 5.x.x.108 or higher

103	Failed to obtain Version Information from CRPE32.DLL

104	Failed to load function from CRPE32.DLL

105	Could not find CRPE32.DLL

106	Print Engine could not be loaded

109	Error freeing library: CRPE32.DLL

110	Could not Allocate Memory for Internal Variables

112	No ReportName assigned

114	Report not found

116	Subscript out of range

118	Item already exists

120	Lookup item not found

130	Failed to Retrieve Error Message from Print Engine

140	Undefined PrintEngine Error

Window

150	Invalid Magnification Value.  Use -1 for Default,

   0,1,2 for ZoomPreview constants, or 25-400 for Zoom values

Printer

170	Printer Name has not been set

175	Failed to obtain Printer Information

180	Output to Fax requires CRPE32 version 7.0 or higher

Subreports

200	Subreport Name not found.

Use "Add" to add a Subreport Name,

or "Retrieve" to obtain the Subreport Names from the Report

205	Cannot Delete Subreports[0]; this is the Main Report

210	Error: SubReport Name not found in Report

LogOnInfo

250	Invalid Table Number

SessionInfo

260	Invalid Table Number

SQL Params

270	Invalid Param Name

280	Value could not be converted to Date

282	Value could not be converted to DateTime

284	Value could not be converted to Time

Parameter Fields

290	Invalid Parameter Name

292	Invalid Number Value

293	Invalid Currency Value

294	Invalid Boolean Value (Proper format: True/False)

296	Invalid Date Value (Proper format: YYYY,MM,DD)

297	Invalid String Value

298	Invalid DateTime Value (Proper format: YYYY,MM,DD HH:MM:SS)

299	Invalid Time Value (Proper format: HH:MM:SS)

305	Error converting string to ValueInfo

Tables

320	Invalid Table Number

322	Invalid BDE Alias Name

SortFields

330	Invalid SortFields Number

332	Invalid SortFields Direction

GroupSortFields

340	Invalid GroupSortFields Number

342	Invalid GroupSortFields Direction

GroupCondition/GroupOptions

350	Invalid GroupCondition Number

352	Invalid GroupOptions Number

354	GroupType and Condition do not match

Sections

360	Invalid Section Code or String

362	Invalid SectionAsCode Value (Value must be > 0)

364	Formula is not available for PH/PF Section:

366	Formula is not available for PH/PF(or RH/RF) Section:

368	Invalid Color Value

370	Invalid SectionMinHeight Height value

Graphs

380	Invalid GraphType Number

382	Invalid GraphOptions Number

383	Invalid GraphOptionInfo Number

384	Invalid GraphText Number

386	Invalid GraphData Number

388	Invalid GraphData Bar Direction

SummaryInfo

400	SummaryInfo Comments cannot be greater than 512 characters

Crystal Reports Print Engine Error Codes

The Crystal Report Engine DLL generates the following error codes when necessary:

Error Code	Explanation

0	No Error.

500	There is not enough memory available to complete the call or an incorrect ODBC handle was specified.

501	You have specified a job number that does not exist.

502	You have specified a handle that does not exist.

503	The string you are calling with PEGetHandleString is too long for the buffer allocated.  If returned by other routines, it means that the string does not end with a null byte.

504	You have specified a report that does not exist in the path.

505	You have made the PEStartPrintJob call without first specifying a print destination.

506	You have tried to set an Nth file name and the file number you specified is out of the existing range. 0 <= fileN < N files.

507	There is an error in the file name you specified.

508	The field number you specified is out of the existing range. 0<=fieldN<= N fields.

509	The program can not add the field name you specified.

510	The program can not add the formula name you specified.

511	Sort direction must be either PE_SF_DESCENDING or PE_SF_ASCENDING. You have specified a sort direction other than those allowed.

512	The Report Engine must be open in order for the call to be successful. Your code is lacking a PEOpenEngine call.

513	The printer driver for the printer you specified is missing or there is no default printer installed.

514	The name you have specified for the export file already exists. You must delete the file and export again or specify a different file.

515	There is a formula error in the replacement formula text. Review the formula syntax and retry. This also returns the formula name and a formula message indicating the source of the error.

516	The group section you specified is now invalid in the report, i.e., a group is based on a formula field and the formula has changed so it is no longer suitable for basing a group on.

517	Only one application can access the Report Engine at one time. There is currently another application using the engine.

518	You have given a bad value as the section code for some function like PESetGroupCondition.

519	There is no print window available to make your call successful (for any call that depends on a print window already existing: PEGetWindowHandle, PECloseWindow, PEPrintWindow).

520	You are trying to start a print job that has already been started. This can happen if you start a print job and then try to start printing again before the previous printing has finished.

521	The summary field specified as a group sort field is invalid or non-existent.

522	There are not enough Windows system resources to process the function.

523	You have specified an invalid group condition.

524	You tried to initiate printing while Crystal Reports was already printing a job.

525	There is something wrong with the report you are trying to open.

526	You have not specified a default printer. Specify a default printer via the Windows Control Panel.

527	Unable to connect to the Server or unable to successfully run the SQL query.  Some of the most common reasons for the error to occur are:

- Database Driver DLLs can not be found.

- LogOnInfo Parameters are not NULL terminated.

- Incorrect Logon Parameters.  Ensure that the ServerName, DatabaseName, UserId, and Password are all valid for the Server that you are trying to logon to.

- Incorrect structSize given for LogOnInfo Structure.  If an incorrect value is given here, a SQL Server error may result.  The correct value for the structSize is 514.

- Incorrect SQL Query or the query generated an ODBC error or server error.

528	You have specified an invalid line number.

529	When printing to file or when sorting, the program requires more room than is available on the disk.

530	In trying to print to file, the program is encountering another file problem besides disk full.

531	You have specified an incorrect password.

532	The database DLL is corrupt.

533	Something is wrong with the database you have specified. You may need to verify using the Database|Verify Database command.

534	The database DLL is corrupt, missing or out of date.

535	You have attempted to log on using incomplete or incorrect session parameters.

536	You have attempted to log on using incomplete or incorrect log on parameters.

537	The table you have specified can not be found.

538	The structure size of the structure parameter has not been set correctly.

539	You have specified an invalid date using the PESetPrintDate function.

540	The DLL required by your export call is either missing or out of date. This error can also be caused by an invalid export options parameter.

541	An export DLL has reported an error.

542	You are using the previous page control in the print window when you are already at the first page of the report.

543	You are using the next page control in the print window when you are already at the last page of the report.

544	Access to report file denied. Another program or user may be using it. If an OLE-based report is already open in CRW and you are trying to open it via CRPE, the call will fail.

545	The user clicked the cancel button.

546	The program can not open the report (which includes an OLE 2.0 object) because OLE 2.0 can not be loaded.

547	You have specified an invalid row or column field in your Cross-Tab report.

548	You are trying to run a Cross-Tab report without specifying a summarized field.

549	You have called PEDecodeExportOptions before first calling PEGetExportOptions.

550	You have used an invalid page number with PEShowNthPage.

552	Returned by PESetNthParam when there is no table in the current report that is based on a stored procedure.

553	The parameter you have specified does not exist in the stored procedure, or the value you have entered is not valid for the specified parameter.

554	The graph specified for the section does not exist.

555	The graph type you have indicated with PESetGraphType is not valid.

556	Returned by PESetGraphData if:

- the report is a Cross-Tab, and colGroupN or rowGroupN is > 1, or

- the report is not a Cross-Tab, and rowGroupN is something other than PE_GRAPH_DATA_NULL_SELECTION or colGroupN+1.

557	Returned by PESetGraphData if the report is not a Cross-Tab, and colGroupN differs from the graph's current value for colGroupN.

558	Returned by PESetGraphText. The graph text structure PEGraphTextInfo contains an invalid entry.

559	Returned by PESetGraphOptions. The graph options structure, PEGraphOptions contains an invalid entry.

560	Returned by PESetMinimumSectionHeight. The section height specified is either negative or 0; it must be a value greater than 0.

561	Returned by PESetNthParameterField. The valueType specified in the PEParameterFieldInfo structure is invalid for a parameter field. It must be one of the following: number, currency, Boolean, date, or string.

562	Returned by PEOpenSubreport. The subreport name passed does not exist.

564	Returned by PESetDialogParentWindow. The parent window handle specified is invalid.

565	Returned by PEZoomPreviewWindow. The zoom factor passed in the level parameter is invalid. It must be 0, 1, 2  >= 25, <= 400,  or one of the defined constants.

567	Returned if the total length of the page header and page footer is greater than the length allotted for a page.

568	Returned if GDI memory gets down to 10%. The program will give this message rather than GPF.

570	Returned when the user passes in an invalid group number. This can happen, for example, when the user passes an invalid group number to PEAddGroup.

571	Invalid Object Format Name.

572	Returned when the user passes in a negative value where a value greater than zero should be passed. This can happen, for example, when the user passes a negative section height to PESetMinimumSectionHeight.

573	Returned when the user passes in an invalid pointer, for example, an invalid structure pointer, an invalid string pointer, etc.

574	Invalid Object Type.

577	Invalid GraphData Type.

582	Invalid Subreport Link Number.

583	Subreport Link already exists.

584	Bad RowCol Value (GraphOptions).

585	Invalid Summary Number (GraphOptions).

586	Invalid GraphData Field Number.

587	Invalid Subreport Number.

588	Invalid Field Scope.

590	Field In Use.

594	Returned when the user passes in an invalid parameter field number, for example, when the user passes an invalid parameter field number to PESetNthParameterField.

595	Invalid Page Margins.

596	Report on Secure Query.

597	Cannot open Secure Query.

598	Invalid Section Number.

599	Returned when the user passes invalid information to PELogonServer, or PELogOffServer. This can happen, for example, if the user does not specify the server name.

606	Table Name exists already.

607	Invalid Cursor.

608	First Pass not finished.

609	Error creating Datasource.

610	Error creating Drill-Down Parameters.

613	Error checking for Datasource changes.

614	Error starting background processing.

619	SQL Server in use.

620	Group Sort Field not set.

621	Cannot set save summaries.

622	Error loading OLAP Database Manager.

623	Error opening OLAP Cube.

624	Error reading OLAP Cube data.

626	Cannot save Query.

627	Cannot read Query data.

629	Main Report field linked.

630	Invalid Mapping Type value.

636	Hit test failed.

637	No SQL Expression by the specified *name* exists in this report.

638	No SQL expression by the specified *number* exists in this report.

639	Not a valid SQL expression.

641	Invalid index for default value of a parameter.

642	The specified PE_PF_* type does not have min/max values.

643	If both min and max values are specified in PESetParameterMinMaxValue, the value types for the min and max must be the same.

645	Cannot link tables.

646	Error creating router.

647	Invalid Field Index.

648	Invalid GraphTitle type.

649	Invalid GraphTitle font type.

650	The type used in a add/set value API for a parameter differs with it's existing type.

651	The value type for both start & end range values must be the same.

652	An operation was attempted on a discrete parameter that is only legal for range parameters or vice versa.

654	An operation was attempted that is disallowed for subreports.

655	Invalid index for current value of a parameter.

656	Operation illegal on linked parameter.

674	Invalid sort method index.

675	Invalid PE_GST_* or PE_GST_* does not match PE_GT_* or PE_GST_* current graph type.

676	One of them members of PEGraphOptionInfo is out of range.

677	One of them members of PEGraphAxisInfo is out of range.

997	Other Error (?).

998	Internal Error (programming error?)

999	Not implemented (formerly "Internal error").


OnExecuteBegin event

See also	Example

Declaration

property OnExecuteBegin: TCrpeCancelEvent;

Type

TCrpeCancelEvent = procedure(Sender: TObject; var Cancel: Boolean) of object;

Description

The OnExecuteBegin event takes place at the start of the Execute method, before the Crystal component values have been sent to the Crystal Reports Print Engine.

See Execute for a fuller explanation of the order of events.


OnExecuteBegin event - See also
Other Events

OnJobOpened

OnExecuteDoneSend

OnExecuteEnd

OnPrintEnded

OnWindowClose

OnError

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnExecuteBegin event - Example
Example

The following example runs a Report to Window.  When the Execute method begins, a message is shown:

procedure TForm1.RunReport;

begin

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

end;

procedure TForm1.Crpe1OnExecuteBegin(Sender: TObject; var Cancel: Boolean);

begin

  ShowMessage('Starting Execute');

end;


OnExecuteDoneSend event

See also	Example

Declaration

property OnExecuteDoneSend: TCrpeCancelEvent;

Type

TCrpeCancelEvent = procedure(Sender: TObject; var Cancel: Boolean) of object;

Description

The OnExecuteDoneSend event takes place within the Execute method, after the Crystal component values have been sent to the Crystal Reports Print Engine, but before the Report is actually run.

See Execute for a fuller explanation of the order of events.


OnExecuteDoneSend event - See also
Other Events

OnJobOpened

OnExecuteBegin

OnExecuteEnd

OnPrintEnded

OnWindowClose

OnError

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnExecuteDoneSend event - Example
Example

The following example runs a Report to Window.  When the Execute method has completed sending all the VCL settings to the Print Engine, a message is shown:

procedure TForm1.RunReport;

begin

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

end;

procedure TForm1.Crpe1OnExecuteDoneSend(Sender: TObject; var Cancel: Boolean);

begin

  ShowMessage('Finished Sending to Print Engine');

end;


OnExecuteEnd event

See also	Example

Declaration

property OnExecuteEnd: TNotifyEvent;

Type

TNotifyEvent = procedure(Sender: TObject) of object;

Description

The OnExecuteEnd event takes place within the Execute method, after the Crystal component values have been sent to the Crystal Reports Print Engine, and after the Report has been run.

See Execute for a fuller explanation of the order of events.


OnExecuteEnd event - See also
Other Events

OnJobOpened

OnExecuteBegin

OnExecuteDoneSend

OnPrintEnded

OnWindowClose

OnError

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnExecuteEnd event - Example
Example

The following example runs a Report to Window.  When the Execute method has finished running the Report, a message is shown:

procedure TForm1.RunReport;

begin

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

end;

procedure TForm1.Crpe1OnExecuteEnd(Sender: TObject);

begin

  ShowMessage('Report was run successfully');

end;


OnJobOpened event

See also	Example

Declaration

property OnJobOpened: TCrpeJobNumEvent;

Type

TCrpeJobNumEvent = procedure(Sender: TObject; const JobNum: Word) of object;

Description

The OnJobOpened event occurs when the PrintJob for a Report is opened.  The PrintJob is opened when a Report is loaded into the Crystal Reports Print Engine (CRPE32.DLL).  This does not occur initially when the ReportName property is set, but happens when any call is made that requires the Report to be loaded into the Print Engine.  An example of this type of call would be any of the Retrieve methods, such as Subreports.Retrieve, ParamFields.Retrieve, etc.  It is at this point that the JobNumber property will have a meaningful value.  Note that it is possible to force the PrintJob open by using the OpenJob method.

The event passes the JobNum variable, which is the internal Job Number that the CRPE assigns to the Job, and which is used as an identifier for all the internal calls made to the CRPE concerning this particular Job.  The Job Number is also available via the component's JobNumber property, but in case the component is being created dynamically within a procedure and may not be visible outside of it, the Job Number is passed in the event.  The JobNum variable can be used to make direct Print Engine DLL calls, such as are used internally in the component, although care must be taken not to modify the PrintJob properties in such a way that the component may not be aware of the changes.


OnJobOpened event - See also
Related

JobNumber

Other Events

OnExecuteBegin

OnExecuteDoneSend

OnExecuteEnd

OnPrintEnded

OnWindowClose

OnError

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnJobOpened event - Example
Example

The following example runs a Report to Window.  When the Window is closed, the Print Job is also closed:

procedure TForm1.RunReport;

begin

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

end;

procedure TForm1.Crpe1OnJobOpened(const JobNum: Word);

begin

  ShowMessage('PrintJob opened successfully');

end;


OnPrintEnded event

See also	Example

Declaration

property OnPrintEnded: TNotifyEvent;

Type

TNotifyEvent = procedure(Sender: TObject) of object;

Description

The OnPrintEnded event takes place within the Execute method, after the Crystal component values have been sent to the Crystal Reports Print Engine, and after the Report has been run.

See Execute for a fuller explanation of the order of events.


OnPrintEnded event - See also
Related

CanCloseEngine

IsJobFinished

PrintEnded

Status

OnWindowClose

Other Events

OnJobOpened

OnExecuteBegin

OnExecuteDoneSend

OnExecuteEnd

OnError

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnPrintEnded event - Example
Example

The following example runs a Report to Printer.  When the Job is finished, the Print Job is also closed:

procedure TForm1.RunReport;

begin

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toPrinter;

Crpe1.Execute;

end;

procedure TForm1.Crpe1OnPrintEnded(Sender: TObject);

begin

  Crpe1.CloseJob;

end;


OnWindowClose event

See also	Example

Declaration

property OnWindowClose : TNotifyEvent;

Type

TNotifyEvent = procedure(Sender: TObject) of object;

Description

The OnWindowClose event takes place within the Execute method, after the Crystal component values have been sent to the Crystal Reports Print Engine, and after the Report has been run.

See Execute for a fuller explanation of the order of events.


OnWindowClose event - See also
Related

CanCloseEngine

IsJobFinished

PrintEnded

Status

OnPrintEnded

Other Events

OnJobOpened

OnExecuteBegin

OnExecuteDoneSend

OnExecuteEnd

OnError

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnWindowClose event - Example
Example

The following example runs a Report to Window.  When the Window is closed, the Print Job is also closed:

procedure TForm1.RunReport;

begin

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

end;

procedure TForm1.Crpe1OnWindowClose(Sender: TObject);

begin

  Crpe1.CloseJob;

end;


OnCreate event

See also	Example

Declaration

property OnCreate : TNotifyEvent;

Type

TNotifyEvent = procedure(Sender: TObject) of object;

Description

The OnCreate event takes place at the end of the internal VCL Create procedure.  It can be used to over-ride some of the default property settings.  This is particularly useful when creating the VCL dynamically, since properties cannot be set with default values as they can be in the Object Inspector when the component is placed on a Delphi Form.

See Execute for a fuller explanation of the order of events.


OnCreate event - See also
Other Events

OnError

OnExecuteBegin

OnExecuteEnd

OnExecuteDoneSend

OnJobOpened

OnPrintEnded

OnWindowClose

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnCreate event - Example
Example

The following example assumes the VCL is being created dynamically, and uses the OnCreate event to over-ride the component defaults:

var

  Crpe1 : TCrpe;

procedure TForm1.RunReport;

begin

Crpe1 := TCrpe.Create(Self);

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

end;

procedure TForm1.Crpe1OnCreate(Sender: TObject);

begin

  Crpe1.LoadEngineOnUse := True;

end;


wOnActivateWindow

See also	Example

Declaration

property wOnActivateWindow: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnActivateWindow event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnActivateWindow takes place just before the Preview Window becomes active, or receives the focus.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnActivateWindow event - See also
Related

wOnDeActivateWindow

SetFocus

Focused

Other WindowEvents

wOnCloseWindow

wOnDrillDetail

wOnDrillGroup

wOnReadingRecords

wOnShowGroup

wOnStartEvent

wOnStopEvent

wOnZoomLevelChange

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnActivateWindow - Example
Example

The following procedure illustrates the wOnActivateWindow Event:

procedure TForm1.Crpe1wOnActivateWindow(WindowHandle: Integer;

  var Cancel: Boolean);

begin

  with Memo1.Lines do

    begin

      Add('wOnActivateWindow Event:');

      Add('  - Window was Activated ');

      Add('  - WindowHandle: ' + IntToStr(WindowHandle));

      Add('');

    end;

  end;

end;


wOnCancelBtnClick

See also	Example

Declaration

property wOnCancelBtnClick: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnCancelBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnCancelBtnClick takes place after the Cancel button on the Preview Window button bar is clicked but before canceling the printing or reading of the database.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnCancelBtnClick - See also
Other Button Events

wOnCloseBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnCancelBtnClick - Example
Example

The following procedure illustrates the wOnCancelBtnClick Event:

procedure TForm1.Crpe1wOnCancelBtnClick(WindowHandle: Integer;

  var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnCancelBtnClick Event:');

    Add('  - Cancel Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnCloseBtnClick

See also	Example

Declaration

property wOnCloseBtnClick: TCrpeCloseButtonClickedEvent;

Types

TCrpeCloseButtonClickedEvent = procedure(WindowHandle: HWnd; ViewIndex: Word; var Cancel: Boolean) of object;

Description

The wOnCloseBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnCloseBtnClick takes place after the Close button on the Preview Window button bar is clicked, but before the Preview Window is closed.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

ViewIndex	- Specifies which View is going to be closed.  The View is the current tab on the Preview Window, which could be the main Preview tab, or one of the open drill-down tabs.  The Preview tab is numbered 0, and the drill-down tabs are numbered from left to right in order.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnCloseBtnClick - See also
Related

wOnCloseWindow

Other Button Events

wOnCancelBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnCloseBtnClick - Example
Example

The following procedure illustrates the wOnCloseBtnClick Event:

procedure TForm1.Crpe1wOnCloseBtnClick(WindowHandle: Integer;

  ViewIndex: Word; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnCloseBtnClick Event:');

    Add('  - Close Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('  - ViewIndex: ' + IntToStr(ViewIndex));

    Add('');

  end;

end;


wOnCloseWindow

See also	Example

Declaration

property wOnCloseWindow: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnCloseWindow event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnCloseWindow takes place just before the Preview Window is closed.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnCloseWindow - See also
Related

wOnCloseBtnClick

CloseWindow

Other WindowEvents

wOnActivateWindow

wOnDeActivateWindow

wOnDrillDetail

wOnDrillGroup

wOnReadingRecords

wOnShowGroup

wOnStartEvent

wOnStopEvent

wOnZoomLevelChange

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnCloseWindow - Example
Example

The following procedure illustrates the wOnCloseWindow Event:

procedure TForm1.Crpe1wOnCloseWindow(WindowHandle: Integer;

  var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnCloseWindow Event:');

    Add('  - Window is being Closed ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnDeActivateWindow

See also	Example

Declaration

property wOnDeActivateWindow: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnDeActivateWindowevent is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnDeActivateWindow takes place when the Preview Window becomes inactive, or loses focus.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnDeActivateWindow - See also
Related

wOnActivateWindow

SetFocus

Focused

Other WindowEvents

wOnCloseWindow

wOnDrillDetail

wOnDrillGroup

wOnReadingRecords

wOnShowGroup

wOnStartEvent

wOnStopEvent

wOnZoomLevelChange

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnDeActivateWindow - Example
Example

The following procedure illustrates the wOnDeActivateWindow Event:

procedure TForm1.Crpe1wOnDeActivateWindow(WindowHandle: Integer;

  var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnDeActivateWindow Event:');

    Add('  - Window was DeActivated ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnDrillDetail

See also	Example

Declaration

property wOnDrillDetail: TCrpeDrillOnDetailEvent;

Types

TCrpeDrillOnDetailEvent = procedure(WindowHandle: HWnd; NSelectedField, NFields: smallint; FieldNames, FieldValues: TStringList; var Cancel: Boolean) of object;

Description

The wOnDrillDetail event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnDrillDetail takes place when a Detail area on the Preview Window is double-clicked.  Note that AllowDrillDown must be True on the WindowButtonBar options before the Event will be returned.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

NSelectedField	- The number of the field that was double-clicked (if any).  This number can be used to locate the field information in the FieldNames and FieldValues stringlists.

NFields	- The total number of Fields in the Detail area that was drilled on.

FieldNames	- A stringlist containing the Names of all the Fields in the applicable detail area.

FieldValues	- A stringlist containing the actual values of the Fields in the applicable detail area.  These items should correspond to the FieldNames stringlist.  NFields can be used to loop through the stringlists:

  	for cnt := 0 to (NFields - 1) do

begin

ShowMessage(FieldNames[cnt]);

ShowMessage(FieldValues[cnt]);

end;

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnDrillDetail - See also
Related

wOnDrillGroup

wOnShowGroup

wOnMouseClick event

Other WindowEvents

wOnActivateWindow

wOnCloseWindow

wOnDeActivateWindow

wOnReadingRecords

wOnStartEvent

wOnStopEvent

wOnZoomLevelChange

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnDrillDetail - Example
Example

The following procedure illustrates the wOnDrillDetail Event:

procedure TForm1.Crpe1wOnDrillDetail(WindowHandle: Integer; NSelectedField, NFields: Smallint; FieldNames, FieldValues: TStringList; var Cancel: Boolean);

var

  cnt : integer;

begin

  with Memo1.Lines do

  begin

    Add('wOnDrillDetail Event:');

    Add('  - Detail Section was drilled ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('  - Number of Fields in Details area: ' + IntToStr(NFields));

    Add('  - Number of Selected Field: ' + IntToStr(NSelectedField));

    Add('  - Field Names: ');

    for cnt := 0 to (FieldNames.Count - 1) do

      Add('      ' + IntToStr(cnt) + '. ' + FieldNames[cnt]);

    Add('  - Field Values: ');

    for cnt := 0 to (FieldValues.Count - 1) do

      Add('      ' + IntToStr(cnt) + '. ' + FieldValues[cnt]);

    Add('');

  end;

end;


wOnDrillGroup

See also	Example

Declaration

property wOnDrillGroup: TCrpeDrillOnGroupEvent;

Types

TCrpeDrillOnGroupEvent = procedure(WindowHandle: HWnd; NGroupLevel: Word; DrillType: TCrDrillDownType; GroupList: TStringList; var Cancel: Boolean) of object;

TCrDrillDownType = (ddOnGroup, ddOnGroupTree, ddOnGraph, ddOnMap, ddOnSubreport);

Description

The wOnDrillGroup event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnDrillGroup takes place when a Group area on the Preview Window is double-clicked or a GroupTree node is Ctrl-clicked.  Note that AllowDrillDown must be True on the WindowButtonBar options before the Event will be returned.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

NGroupLevel	- The number of the Group chosen.  The outer group starts with number 1, so if you use NGroupLevel to find the name of the Group in the GroupList, be sure to decrement it by 1.

DrillType	- The type of drill-down:

ddOnGroup	- a Group area on the Report was double-clicked.

ddOnGroupTree	- a GroupTree node was Ctrl-clicked.

ddOnGraph	- a Graph area was double-clicked.

ddOnMap	- a Map area was double-clicked.

ddOnSubreport	- a Subreport was double-clicked.

GroupList	- A stringlist containing the names of the Groups starting from the outer group and going up to the Group chosen.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.  The two TCrDrillDownType items: ddOnMap and ddOnSubreport, are only available with Crystal 7 and higher.


wOnDrillGroup - See also
Related

wOnDrillDetail

wOnShowGroup

wOnMouseClick event

Other WindowEvents

wOnActivateWindow

wOnCloseWindow

wOnDeActivateWindow

wOnReadingRecords

wOnStartEvent

wOnStopEvent

wOnZoomLevelChange

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnDrillGroup - Example
Example

The following procedure illustrates the wOnDrillGroup Event:

procedure TForm1.Crpe1wOnDrillGroup(WindowHandle: Integer;

  NGroupLevel: Word; DrillType: TCrDrillDownType; GroupList: TStringList;

  var Cancel: Boolean);

var

  cnt: integer;

begin

  with Memo1.Lines do

  begin

    Add('wOnDrillGroup Event:');

    Add('  - Group Section was drilled ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    case DrillType of

      ddOnGroup     : Add('  - DrillDown Type: OnGroup');

      ddOnGroupTree : Add('  - DrillDown Type: OnGroupTree');

      ddOnGraph     : Add('  - DrillDown Type: OnGraph');

      ddOnMap       : Add('  - DrillDown Type: OnMap');

      ddOnSubreport : Add('  - DrillDown Type: OnSubreport');

    end;

    Add('  - GroupLevel: ' + IntToStr(NGroupLevel));

    Add('  - GroupList: ');

    for cnt := 0 to (GroupList.Count - 1) do

      Add('      ' + IntToStr(cnt) + '. ' + GroupList[cnt]);

    Add('');

  end;

end;


wOnExportBtnClick

See also	Example

Declaration

property wOnExportBtnClick: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnExportBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnExportBtnClick takes place after the Export button on the Preview Window button bar is clicked, but before the Export process starts.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnExportBtnClick - See also
Other Button Events

wOnCancelBtnClick

wOnCloseBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnExportBtnClick - Example
Example

The following procedure illustrates the wOnExportBtnClick Event:

procedure TForm1.Crpe1wOnExportBtnClick(WindowHandle: Integer; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnExportBtnClick Event:');

    Add('  - Export Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnFirstPageBtnClick

See also	Example

Declaration

property wOnFirstPageBtnClick: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnFirstPageBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnFirstPageBtnClick takes place after the FirstPage button on the Preview Window button bar is clicked, but before the Report goes to the first page.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnFirstPageBtnClick - See also
Related

Pages

Other Button Events

wOnCancelBtnClick

wOnCloseBtnClick

wOnExportBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnFirstPageBtnClick - Example
Example

The following procedure illustrates the wOnFirstPageBtnClick Event:

procedure TForm1.Crpe1wOnFirstPageBtnClick(WindowHandle: Integer; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnFirstPageBtnClick Event:');

    Add('  - First Page Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnGroupTreeBtnClick

See also	Example

Declaration

property wOnGroupTreeBtnClick: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnGroupTreeBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnGroupTreeBtnClick takes place after the GroupTree button on the Preview Window button bar is clicked, but before showing or hiding the GroupTree.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnGroupTreeBtnClick - See also
Related

wOnShowGroup

Other Button Events

wOnCancelBtnClick

wOnCloseBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnGroupTreeBtnClick - Example
Example

The following procedure illustrates the wOnGroupTreeBtnClick Event:

procedure TForm1.Crpe1wOnGroupTreeBtnClick(WindowHandle: Integer; Visible: Boolean; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnGroupTreeBtnClick Event:');

    Add('  - GroupTree Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('  - GroupTree Visible: ' + BooleanToStr(Visible));

    Add('');

  end;

end;


wOnLastPageBtnClick

See also	Example

Declaration

property wOnLastPageBtnClick: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnLastPageBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnLastPageBtnClick takes place after the LastPage button on the Preview Window button bar is clicked, but before going to the last page.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnLastPageBtnClick - See also
Related

Pages

Other Button Events

wOnCancelBtnClick

wOnCloseBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnLastPageBtnClick - Example
Example

The following procedure illustrates the wOnLastPageBtnClick Event:

procedure TForm1.Crpe1wOnLastPageBtnClick(WindowHandle: Integer; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnLastPageBtnClick Event:');

    Add('  - Last Page Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnNextPageBtnClick

See also	Example

Declaration

property wOnNextPageBtnClick: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnNextPageBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnNextPageBtnClick takes place after the NextPage button on the Preview Window button bar is clicked, but before going to the next page.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnNextPageBtnClick - See also
Related

Pages

Other Button Events

wOnCancelBtnClick

wOnCloseBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnNextPageBtnClick - Example
Example

The following procedure illustrates the wOnNextPageBtnClick Event:

procedure TForm1.Crpe1wOnNextPageBtnClick(WindowHandle: Integer; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnNextPageBtnClick Event:');

    Add('  - Next Page Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnPreviousPageBtnClick

See also	Example

Declaration

property wOnPreviousPageBtnClick: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnPreviousPageBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnPreviousPageBtnClick takes place after the PreviousPage button on the Preview Window button bar is clicked, but before going to the previous page.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnPreviousPageBtnClick - See also
Related

Pages

Other Button Events

wOnCancelBtnClick

wOnCloseBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnPreviousPageBtnClick - Example
Example

The following procedure illustrates the wOnPreviousPageBtnClick Event:

procedure TForm1.Crpe1wOnPreviousPageBtnClick(WindowHandle: Integer; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnPreviousPageBtnClick Event:');

    Add('  - Previous Page Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnPrintBtnClick

See also	Example

Declaration

property wOnPrintBtnClick: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnPrintBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnPrintBtnClick takes place after the Print button on the Preview Window button bar is clicked, but before the printing process starts.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnPrintBtnClick - See also
Other Button Events

wOnCancelBtnClick

wOnCloseBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnPrintBtnClick - Example
Example

The following procedure illustrates the wOnPrintBtnClick Event:

procedure TForm1.Crpe1wOnPrintBtnClick(WindowHandle: Integer; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnPrintBtnClick Event:');

    Add('  - Print Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnPrintSetupBtnClick

See also	Example

Declaration

property wOnPrintSetupBtnClick: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnPrintSetupBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnPrintSetupBtnClick takes place after the PrintSetup button on the Preview Window button bar is clicked, but before showing the Print Setup dialog box.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnPrintSetupBtnClick - See also
Other Button Events

wOnCancelBtnClick

wOnCloseBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnPrintSetupBtnClick - Example
Example

The following procedure illustrates the wOnPrintSetupBtnClick Event:

procedure TForm1.Crpe1wOnPrintSetupBtnClick(WindowHandle: Integer; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnPrintSetupBtnClick Event:');

    Add('  - Print Setup Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnReadingRecords

See also	Example

Declaration

property wOnReadingRecords: TCrpeReadingRecordsEvent;

Types

TCrpeReadingRecordsEvent = procedure(Cancelled: boolean; RecordsRead: longint; RecordsSelected: longint; Done: boolean; var Cancel: boolean) of object;

Description

The wOnReadingRecords event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnReadingRecords takes place during a reading of the database or regenerating saved data process.  It is triggered after a specified amount of time, not after reading every Record.  This event passes the following variables:

Cancelled	- Indicates whether the reading Records is canceled.

RecordsRead	- Indicates how many Records have been read so far.

RecordsSelected	- Indicates how many Records have been selected so far.

Done	- Indicates whether reading Records is finished.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnReadingRecords - See also
Related

Records

Other WindowEvents

wOnActivateWindow

wOnCloseWindow

wOnDeActivateWindow

wOnDrillDetail

wOnDrillGroup

wOnShowGroup

wOnStartEvent

wOnStopEvent

wOnZoomLevelChange

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnReadingRecords - Example
Example

The following procedure illustrates the wOnReadingRecords Event:

procedure TForm1.Crpe1wOnReadingRecords(Cancelled: Boolean; RecordsRead, RecordsSelected: Integer; Done: Boolean; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnReadingRecords Event:');

    Add('  - Reading Records Event triggered ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('  - Records Read: ' + IntToStr(RecordsRead));

    Add('  - Records Selected: ' + IntToStr(RecordsSelected));

    Add('  - Cancelled: ' + BooleanToStr(Cancelled));

    Add('  - Done: ' + BooleanToStr(Done));

    Add('');

  end;

end;


wOnRefreshBtnClick

See also	Example

Declaration

property wOnRefreshBtnClick: TCrpeGeneralPrintWindowEvent;

Types

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Description

The wOnRefreshBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnRefreshBtnClick takes place after the Refresh button on the Preview Window button bar is clicked, but before refreshing the data.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnRefreshBtnClick - See also
Other Button Events

wOnCancelBtnClick

wOnCloseBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnRefreshBtnClick - Example
Example

The following procedure illustrates the wOnRefreshBtnClick Event:

procedure TForm1.Crpe1wOnRefreshBtnClick(WindowHandle: Integer; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnRefreshBtnClick Event:');

    Add('  - Refresh Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('');

  end;

end;


wOnSearchBtnClick

See also	Example

Declaration

property wOnSearchBtnClick: TCrpeSearchButtonClickedEvent;

Types

TCrpeSearchButtonClickedEvent = procedure(WindowHandle: HWnd; SearchString: string; var Cancel: Boolean) of object;

Description

The wOnSearchBtnClick event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

weOnSearchBtnClick takes place after the Search button on the Preview Window button bar is clicked, but before the search starts.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

SearchString	- The text that was entered into the Search String field on the Preview Window.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnSearchBtnClick - See also
Other Button Events

wOnCancelBtnClick

wOnCloseBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnSearchBtnClick - Example
Example

The following procedure illustrates the wOnSearchBtnClick Event:

procedure TForm1.Crpe1wOnSearchBtnClick(WindowHandle: Integer; SearchString: string; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnSearchBtnClick Event:');

    Add('  - Search Button clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('  - Search String: ' + SearchString);

    Add('');

  end;

end;


wOnShowGroup

See also	Example

Declaration

property wOnShowGroup: TCrpeShowGroupEvent;

Types

TCrpeShowGroupEvent = procedure(WindowHandle: HWnd; NGroupLevel: Word; GroupList: TStringList; var Cancel: Boolean) of object;

Description

The wOnShowGroup event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnShowGroup takes place after one of the GroupTree nodes is clicked on, but before showing that group.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

NGroupLevel	- The number of the Group chosen.  The outer group starts with number 1, so if you use NGroupLevel to find the name of the Group in the GroupList, be sure to decrement it by 1.

GroupList	- A stringlist containing the names of the Groups starting from the outer group and going up to the Group chosen.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnShowGroup - See also
Related

wOnDrillGroup

wOnDrillDetail

Other WindowEvents

wOnActivateWindow

wOnCloseWindow

wOnDeActivateWindow

wOnDrillDetail

wOnDrillGroup

wOnReadingRecords

wOnStartEvent

wOnStopEvent

wOnZoomLevelChange

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnShowGroup - Example
Example

The following procedure illustrates the wOnShowGroup Event:

procedure TForm1.Crpe1wOnShowGroup(WindowHandle: Integer; NGroupLevel: Word; GroupList: TStringList; var Cancel: Boolean);

var

  cnt: integer;

begin

  with Memo1.Lines do

  begin

    Add('wOnShowGroup Event:');

    Add('  - Group Tree was clicked ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('  - GroupLevel: ' + IntToStr(NGroupLevel));

    Add('  - GroupList: ');

    for cnt := 0 to (GroupList.Count - 1) do

      Add('      ' + IntToStr(cnt) + '. ' + GroupList[cnt]);

    Add('');

  end;

end;


wOnStartEvent

See also	Example

Declaration

property wOnStartEvent: TCrpeStartEvent;

Types

TCrpeStartEvent = procedure(Destination: TCrStartEventDestination; var Cancel: Boolean) of object;

TCrStartEventDestination = (seNoWhere, seToWindow, seToPrinter, seToExport, seFromQuery);

Description

The wOnStartEvent is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnStartEvent takes place before the Report Engine starts a process.  A process can be printing to the printer, exporting, printing to a window, or generating pages when navigating through the Preview Window.  This event passes the following variables:

Destination 	- The destination of the current process.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnStartEvent - See also
Related

wOnStopEvent

Other WindowEvents

wOnActivateWindow

wOnCloseWindow

wOnDeActivateWindow

wOnDrillDetail

wOnDrillGroup

wOnReadingRecords

wOnShowGroup

wOnZoomLevelChange

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnStartEvent - Example
Example

The following procedure illustrates the wOnStartEvent Event:

procedure TForm1.Crpe1wOnStartEvent(Destination: TCrStartEventDestination;

  var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnStartEvent Event:');

    Add('  - An Event was Started ');

    case Destination of

      seNoWhere   : Add('  - Destination: seNoWhere');

      seToWindow  : Add('  - Destination: seToWindow');

      seToPrinter : Add('  - Destination: seToPrinter');

      seToExport  : Add('  - Destination: seToExport');

      seFromQuery : Add('  - Destination: seFromQuery');

    end;

    Add('');

  end;

end;


wOnStopEvent

See also	Example

Declaration

property wOnStopEvent: TCrpeStopEvent;

Types

TCrpeStopEvent = procedure(Destination: TCrStartEventDestination; JobStatus: TCrStopEventJobStatus; var Cancel: Boolean) of object;

TCrStartEventDestination = (seNoWhere, seToWindow, seToPrinter, seToExport, seFromQuery);

TCrStopEventJobStatus = (seNotStarted, seInProgress, seCompleted, seFailed, seCancelled, seHalted);

Description

The wOnStopEvent is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnStopEvent takes place whenever a process has finished.  This event passes the following variables:

Destination 	- The destination of the process.

JobStatus	- The status of the process.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using Crystal 6.0 or higher to use Window Events.


wOnStopEvent - See also
Related

wOnStartEvent

Other WindowEvents

wOnActivateWindow

wOnCloseWindow

wOnDeActivateWindow

wOnDrillDetail

wOnDrillGroup

wOnReadingRecords

wOnShowGroup

wOnZoomLevelChange

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnStopEvent - Example
Example

The following procedure illustrates the wOnStopEvent Event:

procedure TForm1.Crpe1wOnStopEvent(Destination: TCrStartEventDestination; JobStatus: TCrStopEventJobStatus; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnStopEvent Event:');

    Add('  - An Event was Stopped ');

    case Destination of

      seNoWhere   : Add('  - Destination: seNoWhere');

      seToWindow  : Add('  - Destination: seToWindow');

      seToPrinter : Add('  - Destination: seToPrinter');

      seToExport  : Add('  - Destination: seToExport');

      seFromQuery : Add('  - Destination: seFromQuery');

    end;

    case JobStatus of

      seUndefined  : Add('  - JobStatus: seUndefined');

      seNotStarted : Add('  - JobStatus: seNotStarted');

      seInProgress : Add('  - JobStatus: seInProgress');

      seCompleted  : Add('  - JobStatus: seCompleted');

      seFailed     : Add('  - JobStatus: seFailed');

      seCancelled  : Add('  - JobStatus: seCancelled');

      seHalted     : Add('  - JobStatus: seHalted');

    end;

    Add('');

  end;

end;


wOnZoomLevelChange

See also	Example

Declaration

property wOnZoomLevelChange : TCrpeZoomLevelChangingEvent;

Types

TCrpeZoomLevelChangingEvent = procedure(WindowHandle: HWnd; ZoomLevel: Word; var Cancel: Boolean) of object;

Description

The wOnZoomLevelChange event is one of the 22 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnZoomLevelChange takes place after the zoom setting is changed via the drop-down Zoom Level combo box on the button bar of the Preview Window, but before the Preview Zoom Level is actually changed.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

ZoomLevel	- This value can be a value from 25 to 400, indicating a magnification percentage, or it can be one of the following constants:

1	- Page Width

2	- Whole Page

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

You must be using SCR 6 or higher to use Window Events.


wOnZoomLevelChange - See also
Related

WindowZoom

Other ButtonEvents

wOnCancelBtnClick

wOnCloseBtnClick

wOnExportBtnClick

wOnFirstPageBtnClick

wOnGroupTreeBtnClick

wOnLastPageBtnClick

wOnNextPageBtnClick

wOnPreviousPageBtnClick

wOnPrintBtnClick

wOnPrintSetupBtnClick

wOnRefreshBtnClick

wOnSearchBtnClick

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnZoomLevelChange - Example
Example

The following procedure illustrates the wOnZoomLevelChange Event:

procedure TForm1.Crpe1wOnZoomLevelChange(WindowHandle: Integer;

  ZoomLevel: Word; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnZoomLevelChange Event:');

    Add('  - Zoom Level was changed ');

    Add('  - WindowHandle: ' + IntToStr(WindowHandle));

    Add('  - Zoom Level: ' + IntToStr(ZoomLevel));

    Add('');

  end;

end;


OnFieldMapping event

See also	Example

Declaration

property OnFieldMapping : TCrpeFieldMappingEvent;

Types

TCrpeFieldMappingEvent = procedure(var ReportFields: TList; var DatabaseFields: TList; var Cancel: Boolean) of object;

TCrFieldValueType = (fvUnknown, fvInt8s, fvInt8u, fvInt16s, fvInt16u, fvInt32s, fvInt32u, fvNumber, fvCurrency, fvBoolean, fvDate, fvTime, fvString, fvTransientMemo, fvPersistentMemo, fvBlob, fvDateTime, fvBitmap, fvIcon, fvPicture, fvOle, fvGraph);

TCrFieldMappingInfo = class(TPersistent)

public

  property TableName : string

  property FieldName : string

  property FieldType : TCrFieldValueType

  property MapTo : integer

end;

Description

The OnFieldMapping event can be used at runtime to handle remapping of Database Fields whose names have changed since the Report was designed.  This event will only be invoked if the FieldMapping property is set to fmEvent, and the VerifyDatabase method has been called.  This event passes two TList objects as parameters, and a boolean Cancel parameter.

The two TList objects contain TCrFieldMappingInfo classes, one item in the ReportFields list for each database field used in the Report, and one item in each DatabaseFields list for each database field in the physical table(s).  The MapTo property of the TCrFieldMappingInfo class is used to set which ReportField goes with which DatabaseField.  Any unmapped ReportFields and DatabaseFields have a MapTo value of -1.

See the Example for more details.

Note

The Cancel parameter is not working properly at this time.  This is not a problem with the VCL but rather the CRPE32.DLL.


OnFieldMapping event - See also
Related

FieldMapping

RetrieveFieldMapping

SendFieldMapping

VerifyDatabase

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnFieldMapping event - Example
Example

The following example shows how to read the Report and Database fields passed in the OnFieldMapping event.  The Table and Field name are attached to the String part of a TStringList, and the Object part of the TStringList contains a pointer to the original TCrFieldMappingInfo class.  This kind of handling makes it easy to pass the Table.FieldName strings into a ListBox or ComboBox, if you plan to make your own Mapping Dialog (See the Sample App included with the VCL for a working demonstration of this).

procedure TForm.Crpe1OnFieldMapping(var ReportFields,

  DatabaseFields: TList; var Cancel: Boolean);

var

  RptFields   : TCrFieldMappingInfo;

  DBFields    : TCrFieldMappingInfo;

  slRptFields : TStringList;

  slDBFields  : TStringList;

  cnt         : integer;

begin

  slRptFields := TStringList.Create;

  slDBFields := TStringList.Create;

  {Get unmapped ReportFields}

  for cnt := 0 to ReportFields.Count - 1 do

  begin

    RptFields := TCrFieldMappingInfo(ReportFields[cnt]);

    if RptFields.MapTo = -1 then

    begin

      slRptFields.Add(RptFields.TableName + '.' + RptFields.FieldName);

      slRptFields.Objects[slRptFields.Count - 1] := ReportFields[cnt];

    end;

  end;

  {Get unmapped DatabaseFields}

  for cnt := 0 to DatabaseFields.Count - 1 do

  begin

    DBFields := TCrFieldMappingInfo(DatabaseFields[cnt]);

    if DBFields.MapTo = -1 then

    begin

      slDBFields.Add(DBFields.TableName + '.' + DBFields.FieldName);

      slDBFields.Objects[slDBFields.Count - 1] := DatabaseFields1[cnt];

      DBFields.MapTo := cnt;

    end;

  end;

  {When you want to map a ReportField to a DatabaseField, you can simply cast the StringList Object back into the TCrFieldMappingInfo variable, and then set the MapTo property}

  RptFields := TCrFieldMappingInfo(slRptFields.Objects[x]);

  DBFields := TCrFieldMappingInfo(slDBFields.Objects[y]);

  {Set the MapTo number to the Database field item number}

  RptFields.MapTo := DBFields.MapTo;

  {Remember to free the StringLists when done}

  slRptFields.Free;

  slDBFields.Free;

end;


OnGetVersion event

See also	Example

Declaration

property OnGetVersion : TCrpeVersionEvent;

Types

TCrpeVersionEvent = procedure(Sender: TObject; var Major, Minor : integer) of object;

Description

The OnGetVersion event allows the developer to over-ride the VCL's built-in version check of the CRPE32.DLL.  The VCL does a File Version check on CRPE32.DLL and will not run with anything less than 5.x.x.108 or higher.  Normally, over-riding this safety feature would not be a wise thing to do, but we have come across a few variant versions of CRPE32 that have odd version numbers, so this event can be used to handle such circumstances.

The two important parameters are the Major and Minor integers.  Major refers to the first number sequence in the File Version, such as 5, 6, or 7.  Minor refers to the last number sequence, such as 108, 135, 151, etc.  These can be set as desired, and the VCL will then assume that it is dealing with that particular version of CRPE32.DLL.

Note

Be careful about setting the Major version too high.  If the VCL does not find certain procedures in CRPE32.DLL that it expects to find in a particular version, errors will result.


OnGetVersion event - See also
Related

Version

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnGetVersion event - Example
Example

The following example shows how to over-ride the VCL's version check on CRPE32.DLL using the OnGetVersion event:

procedure TForm.Crpe1OnGetVersion(Sender: TObject; var Major, Minor : integer);

begin

  Major := 5;

  Minor := 108;

end;


OnPrinterSend event

See also	Example

Declaration

property OnPrinterSend: TCrpeCancelEvent;

Types

TCrpeCancelEvent = procedure(Sender: TObject; var Cancel: Boolean) of object;

Description

The OnPrinterSend event occurs just before the Printer property values are sent to the Crystal Reports Print Engine.  Putting an event here allows the developer a "last chance" to over-ride any Printer DevMode settings that the VCL may be changing via properties such as Orientation and PreserveRptSettings.  This event should not be required under normal circumstances.

Note

Setting the Cancel parameter to true will cause the Printer.Send to abort. If this is done during the Crpe1.Execute method, execution of the Report will also stop.


OnPrinterSend event - See also
Related

Printer

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


OnPrinterSend event - Example
Example

The following example shows how the OnPrinterSend event can be used to over-ride DevMode settings:

procedure TForm.Crpe1OnPrinterSend(Sender: TObject; var Cancel: Boolean);

begin

  TCrpe(Sender).Printer.PMode^.dmCopies := 3;

end;


wOnMouseClick event

See also	Example

Declaration

property wOnMouseClick : TCrpeMouseClickEvent;

Types

TCrpeMouseClickEvent = procedure(WindowHandle: HWnd; MouseInfo: TCrMouseInfo; FieldValue: string; FieldType: TCrParamFieldType; Section: string; ObjectHandle: Hwnd; var Cancel: Boolean) of object;

TCrMouseClickAction = (mbNotSupported, mbDown, mbUp);

TCrMouseClickType = (mcLeft, mcRight, mcMiddle);

TCrMouseInfo = record

  Action     : TCrMouseClickAction;

  Button     : TCrMouseClickType;

  ShiftKey   : Boolean;

  ControlKey : Boolean;

  x,y        : integer;

end;

TCrParamFieldType = (pfNumber, pfCurrency, pfBoolean, pfDate, pfString, pfDateTime, pfTime, pfInteger, pfColor, pfChar, pfLong, pfNoValue);

Description

The wOnMouseClick event is one of the 23 events associated with the Crystal Reports Preview Window.  These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnMouseClick takes place when the Mouse buttons are clicked on the Preview Window.  This event passes the following variables:

WindowHandle 	- The Handle to the current Preview Window.

MouseInfo	- A structure with various items that give information about the Mouse click.

Action - A TCrMouseClickAction value.

Button - A TCrMouseClickType value.

ShiftKey - True if the Shift key was held down.

ControlKey - True if the Control key was held down.

x,y - The actual mouse co-ordinates.

FieldValue	- The actual value of the database field or label that was clicked on (if any).

FieldType	- A TCrParamFieldType value that defines the data type of the field that was clicked on (if any).

Section	- The Section name of the Report area that the Mouse was clicked in. This will be in the Crystal Reports short section-naming convention, as used throughout the VCL.

ObjectHandle	- The handle of the Report object that was clicked on (if any).  This number represents the order of the object in the Crystal Reports design-view page, from top to bottom, left to right.

Cancel	- A variable that can be set to True to cancel the normal Preview Window response to the Event.

Note

The wOnMouseClick event is only available with Seagate Crystal Reports 7 or higher.


wOnMouseClick event - See also
Related

wOnDrillDetail

wOnDrillGroup

wOnShowGroup

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


wOnMouseClick event - Example
Example

The following procedure illustrates the wOnMouseClick event:

procedure Crpe1wOnMouseClick(WindowHandle: Hwnd; MouseInfo: TCrMouseInfo; FieldValue: String; FieldType: TCrParamFieldType; Section: String; ObjectHandle: HWnd; var Cancel: Boolean);

begin

  with Memo1.Lines do

  begin

    Add('wOnMouseClick Event:');

    case MouseInfo.Button of

      mcLeft   : Add('  - Button: Left Mouse Click');

      mcRight  : Add('  - Button: Right Mouse Click');

      mcMiddle : Add('  - Button: Middle Mouse Click');

    end;

    case MouseInfo.Action of

      mbNotSupported : Add('  - Action: Not Supported');

      mbDown         : Add('  - Action: Mouse Button Down');

      mbUp           : Add('  - Action: Mouse Button Up');

    end;

    if MouseInfo.ShiftKey = True then

      Add('  - ShiftKey: True')

    else

      Add('  - ShiftKey: False');

    if MouseInfo.ControlKey = True then

      Add('  - ControlKey: True')

    else

      Add('  - ControlKey: False');

    Add('  - X Coordinate: ' + IntToStr(MouseInfo.x));

    Add('  - Y Coordinate: ' + IntToStr(MouseInfo.y));

    Add('  - FieldValue: ' + FieldValue);

    case Ord(FieldType) of

      0 {pfNumber}   : Add('  - FieldType: pfNumber');

      1 {pfCurrency} : Add('  - FieldType: pfCurrency');

      2 {pfBoolean}  : Add('  - FieldType: pfBoolean');

      3 {pfDate}     : Add('  - FieldType: pfDate');

      4 {pfString}   : Add('  - FieldType: pfString');

      5 {pfDateTime} : Add('  - FieldType: pfDateTime');

      6 {pfTime}     : Add('  - FieldType: pfTime');

      7 {pfInteger}  : Add('  - FieldType: pfInteger');

      8 {pfColor}    : Add('  - FieldType: pfColor');

      9 {pfChar}     : Add('  - FieldType: pfChar');

      10{pfLong}     : Add('  - FieldType: pfLong');

      11{pfNoValue}  : Add('  - FieldType: pfNoValue');

    end;

    Add('  - Section: ' + Section);

    Add('  - ObjectHandle: ' + IntToStr(ObjectHandle));

    Add('');

  end;

end;


Types

See also	Enumerated Types	Event Types	Property Types

Enumerated Types / Special-Length Types

General

TCrReportName = string;

TCrBoolean = (cFalse, cTrue, cDefault);

TCrOutput = (toWindow, toPrinter, toExport);

TCrState = (crsSetup, crsInit);

TCrError = (errVCL, errEngine);

TCrErrorOption = (errNoOption, errFormula, errPaging, errCancelDialog, errFormatFormulaName, errLinkedParameter);

Export

TCrColumnWidth = (ByArea, ByConstant);

TCrExportAppName = string;

TCrExportFileName = string;

TCrExportType = (Records, TabSeparated, Ascii, Dif, Csv, CharacterSeparated, TabSeparatedText, CrystalReportRPT, LotusWK1, LotusWK3, LotusWKS, RTF, WordForWindows, ExcelXLS, HTML30, HTML32ext, HTML32std, ODBCTable, PaginatedText, ReportDefinition);

TCrExportDestination = (toFile, toEmailViaMapi, toEmailViaVIM, toEmailViaSMI, toMSExchange, toLotusNotes, toApplication);

TCrExportExcelType = (Excel2, Excel3, Excel4, Excel5, Excel5Extended, Excel7, Excel7Tab, Excel8, Excel8Tab);

FieldMapping

TCrFieldMappingInfo = class(TPersistent)

public

  property TableName : string

  property FieldName : string

  property FieldType : TCrFieldValueType

  property MapTo : integer

end;

TCrFieldMappingType = (fmAuto, fmPrompt, fmEvent);

TCrFieldValueType = (fvUnknown, fvInt8s, fvInt8u, fvInt16s, fvInt16u, fvInt32s, fvInt32u, fvNumber, fvCurrency, fvBoolean, fvDate, fvTime, fvString, fvTransientMemo, fvPersistentMemo, fvBlob, fvDateTime, fvBitmap, fvIcon, fvPicture, fvOle, fvGraph);

Formulas

TCrAreaFormatFormula = (afSuppress, afHide, afNewPageBefore, afNewPageAfter, afKeepTogether, afResetPageNAfter, afPrintAtBottomOfPage);

TCrSectionFormatFormula = (sfSuppress, sfPrintAtBottomOfPage,   sfNewPageBefore, sfNewPageAfter, sfResetPageNAfter, sfKeepTogether, sfSuppressBlankSection, sfUnderlaySection, sfBackgroundColor);

Graphs

TCrGraphAxisNumber = integer;

TCrGraphBarDirection = (bdHorizontal, bdVertical, bdDefault);

TCrGraphBarSize = (gbsDefault, gbsMinimum, gbsSmall, gbsAverage, gbsLarge, gbsMaximum);

TCrGraphDataPoints = (gdpDefault, gdpNone, gdpShowLabel, gdpShowValue);

TCrGraphColor  = (gcDefault, gcColor, gcMonochrome);

TCrGraphDirection = (Rows, Cols, RowCol, ColRow, Unknown);

TCrGraphDVType = (gdvDefault, gdvAutomatic, gdvManual);

TCrGraphGridLines = (gglDefault, gglNone, gglMinor, gglMajor, gglMajorAndMinor);

TCrGraphDataNumber = integer;

TCrGraphLegend = (glDefault, glNone, glUpperRight, glBottomCenter, glTopCenter, glRight, glLeft);

TCrGraphMarkerShape = (gshDefault, gshRectangle, gshCircle, gshDiamond, gshTriangle);

TCrGraphMarkerSize = (gmsDefault, gmsSmall, gmsMediumSmall, gmsMedium, gmsMediumLarge, gmsLarge);

TCrGraphNumberFormat = (gnfDefault, gnfNoDecimal, gnfOneDecimal, gnfTwoDecimal, gnfCurrencyNoDecimal, gnfCurrencyTwoDecimal, gnfPercentNoDecimal, gnfPercentOneDecimal, gnfPercentTwoDecimal);

TCrGraphOptionInfoNumber = integer;

TCrGraphOptionsNumber = integer;

TCrGraphPieSize = (gpsDefault, gpsMinimum, gpsSmall, gpsAverage, gpsLarge, gpsMaximum);

TCrGraphPieSlice = (gslDefault, gslNone, gslSmall, gslLarge);

TCrGraphTextNumber = integer;

TCrGraphTextType = string; {128 max in length}

TCrGraphType = (

  {Bar: 0..5}

    barSideBySide, barStacked, barPercent, bar3DSideBySide, bar3DStacked,

    bar3DPercent,

  {Line: 6..11}

    lineRegular, lineStacked, linePercent, lineWithMarkers,

    lineStackedWithMarkers, linePercentWithMarkers,

  {Area: 12..17}

    areaAbsolute, areaStacked, areaPercent, area3DAbsolute, area3DStacked,

    area3DPercent,

  {Pie: 18..21}

    pieRegular, pie3DRegular, pieMultiple, pieMultiProp,

    {Doughnut: 22..24}

    doughnutRegular, doughnutMultiple, doughnutMultiProp,

  {3D Riser: 25..28}

    ThreeDRegular, ThreeDPyramid, ThreeDOctagon, ThreeDCutCorners,

  {3D Surface: 29..31}

    ThreeDSurfaceRegular, ThreeDSurfaceWithSides, ThreeDSurfaceHoneyComb,

  {XYScatter: 32..35}

    XYScatter, XYScatterDualAxis, XYScatterLabeled, XYScatterDualAxisLabeled,

  {Radar: 36..38}

    radarRegular, radarStacked, radarDualAxis,

  {Bubble: 39,40}

    bubbleRegular, bubbleDualAxis,

  {StockHiLo: 41..46}

    stockHiLo, stockHiLoDualAxis, stockHiLoOpen, stockHiLoOpenDualAxis,

    stockHiLoOpenClose, stockHiLoOpenCloseDualAxis,

  {User Defined: 47}

    userDefinedGraph,

  {Unknown: 48..59}

    unknownBar, unknownLine, unknownArea, unknownPie, unknownDoughnut,

    unknown3DRiser, unknown3DSurface, unknownXYScatter, unknownRadar,

    unknownBubble, unknownStockHiLo, unknownGraphType);

TCrGraphViewingAngle = (gvaDefault, gvaStandard, gvaTall, gvaTop, gvaDistorted, gvaShort, gvaGroupEye, gvaGroupEmphasis, gvaFewSeries, gvaFewGroups, gvaDistortedStd, gvaThickGroups, gvaShorter, gvaThickSeries, gvaThickStd, gvaBirdsEye, gvaMax);

Margins

TCrMarginTwips = -2..PE_SM_DEFAULT;  {32768}

ParamFields

TCrParamFieldName = string;

TCrParamFieldReportName = string;

TCrParamFieldSource = (psReport, psStoredProc, psQuery);

TCrParamFieldType = (pfNumber, pfCurrency, pfBoolean, pfDate, pfString, pfDateTime, pfTime, pfInteger, pfColor, pfChar, pfLong, pfNoValue);

TCrParamInfoValueType = (vtRanges, vtDiscrete);

TCrRangeBounds = (IncludeStartAndEnd, IncludeStartOnly, IncludeEndOnly, ExcludeStartAndEnd);

TCrPickListSortMethod = (psmNoSort, psmAlphaNumericAscending, psmAlphaNumericDescending, psmNumericAscending, psmNumericDescending, psmDefaultSort);

Printer/PrintOptions

TCrPrinterDevice = class

  Driver, Device, Port: string;

TCrPrinterName = string;

TCrCollation = (Uncollated, Collated, DefaultCollation);

TCrOrientation = (orDefault, orPortrait, orLandscape);

TCrPreserveRptSet = (prOrientation, prPaperSize, prPaperSource);

TCrPreserveRptSettings = set of TCrPreserveRptSet;

TCrPrintFileName = string;

ReportOptions

TCrDateTimeType = (dtConvertToString, dtConvertToDate, dtKeepAsDateTime, dtDefault);

SectionFont

TCrFontCharSet = (fcAnsi, fcDefault, fcSymbol, fcShiftJis, fcHangeul, fcChineseBig5, fcOEM);

TCrFontFamily = (ffDefault, ffRoman, ffSwiss, ffModern, ffScript, ffDecorative);

TCrFontScope = (fsFields, fsText, fsBoth);

TCrFontWeight = (fwDefault, fwThin, fwExtraLight, fwLight, fwNormal, fwMedium, fwSemiBold, fwBold, fwExtraBold, fwHeavy);

Sort/Group

TCrSortDirection = (sdDescending, sdAscending, sdDefault);

TCrGroupType = (gtOther, gtDate, gtBoolean, gtTime);

TCrGroupDirection = (gdDescending, gdAscending, gdOriginal, gdSpecified, gdDefault);

TCrGroupCondition = (AnyChange, dateDaily, dateWeekly, dateBiWeekly, dateSemiMonthly, dateMonthly, dateQuarterly, dateSemiAnnually, dateAnnually, boolToYes, boolToNo, boolEveryYes, boolEveryNo, boolNextIsYes, boolNextIsNo, timeBySecond, timeByMinute, timeByHour, timeByAMPM);

TCrTopNOptions = (tnUnsorted, tnSorted, tnTopN, tnBottomN, tnDefault);

SQL

TCrConnectMethod = (useConnect, useLogOnInfo);

TCrStoredProcParamName = string;

TCrStoredProcParamType = (spLongVarChar, spBinary, spVarBinary,     spLongVarBinary, spBigInt, spTinyInt, spBit, spChar, spNumeric, spDecimal, spInteger, spSmallInt, spFloat, spReal, spDouble, spDate, spTime, spTimeStamp, spVarChar);

SummaryInfo

TCrSummaryString = string;

Tables

TCrTableType = (ttUnknown, ttStandard, ttSQL, ttStoredProcedure);

Window

TCrFormBorderStyle = bsNone..bsDialog;

TCrZoomMagnification = -1..400;

TCrZoomPreview = (pwNormal, pwPageWidth, pwWholePage, pwDefault);

Window Cursor

TCrWindowCursor = (wcDefault, wcArrow, wcCross, wcIBeam, wcUpArrow, wcSizeAll, wcSizeNWSE, wcSizeNESW, wcSizeWE, wcSizeNS, wcNo, wcWait, wcAppStart, wcHelp, wcMagnify);

Window Events

TCrDrillDownType = (ddOnGroup, ddOnGroupTree, ddOnGraph, ddOnMap, ddOnSubreport);

TCrMouseClickAction = (mbNotSupported, mbDown, mbUp);

TCrMouseClickType = (mcLeft, mcRight, mcMiddle);

TCrMouseInfo = record

  Action     : TCrMouseClickAction;

  Button     : TCrMouseClickType;

  ShiftKey   : Boolean;

  ControlKey : Boolean;

  x, y       : integer;

end;

TCrStartEventDestination = (seNoWhere, seToWindow, seToPrinter, seToExport, seFromQuery);

TCrStopEventJobStatus = (seUndefined, seNotStarted, seInProgress, seCompleted, seFailed, seCancelled, seHalted);

Event Types

TCrpeCancelEvent = procedure(Sender: TObject; var Cancel: Boolean) of object;

TCrpeCloseButtonClickedEvent = procedure(WindowHandle: HWnd; ViewIndex: Word; var Cancel: Boolean) of object;

TCrpeDrillOnDetailEvent = procedure(WindowHandle: HWnd; NSelectedField: smallint; NFields: smallint; FieldNames: TStringList; FieldValues: TStringList; var Cancel: Boolean) of object;

TCrpeDrillOnGroupEvent = procedure(WindowHandle: HWnd; NGroupLevel: Word; DrillType: TCrDrillDownType; GroupList: TStringList; var Cancel: Boolean) of object;

TCrpeErrorEvent = procedure(Sender: TObject; const ErrorNum: smallint; const ErrorString: string; var IgnoreError: TCrBoolean) of object;

TCrpeFieldMappingEvent = procedure(var ReportFields: TList; var DatabaseFields: TList; var Cancel: Boolean) of object;

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

TCrpeGroupTreeButtonClickedEvent = procedure(WindowHandle: HWnd; Visible: boolean; var Cancel: Boolean) of object;

TCrpeJobNumEvent = procedure(Sender: TObject; const JobNum: Word) of object;

TCrpeMouseClickEvent = procedure(WindowHandle: HWnd; MouseInfo: TCrMouseInfo; FieldValue: string; FieldType: TCrParamFieldType; Section: string; ObjectHandle: Hwnd; var Cancel: Boolean) of object;

TCrpePrinterEvent = procedure(Sender: TObject; var PDMode: PDevMode; var Cancel: Boolean) of object;TCrpeReadingRecordsEvent = procedure(Cancelled: boolean; RecordsRead: LongInt; RecordsSelected: LongInt; Done: boolean; var Cancel: Boolean) of object;

TCrpeSearchButtonClickedEvent = procedure(WindowHandle: HWnd; SearchString: string; var Cancel: Boolean) of object;

TCrpeShowGroupEvent = procedure(WindowHandle: HWnd; NGroupLevel: Word; GroupList: TStringList; var Cancel: Boolean) of object;

TCrpeStartEvent = procedure(Destination: TCrStartEventDestination; var Cancel: Boolean) of object;

TCrpeStopEvent = procedure(Destination:  TCrStartEventDestination; JobStatus: TCrStopEventJobStatus; var Cancel: Boolean) of object;

TCrpeVersionEvent = procedure(Sender: TObject; var Major, Minor: integer) of object;

TCrpeZoomLevelChangingEvent = procedure(WindowHandle: HWnd; ZoomLevel: Word; var Cancel: Boolean) of object;

Custom Property Field Types

TCrAreaFormatSection = string;

TCrAreaFormatFormulasSection = string;

TCrExportAppName = string;

TCrExportFileName = string;

TCrExpressionName = string;

TCrFormulaName = string;

TCrGraphAxisNumber = integer;

TCrGraphDataNumber = integer;

TCrGraphNumber = integer;

TCrGraphOptionInfoNumber = integer;

TCrGraphOptionsNumber = integer;

TCrGraphTextNumber = integer;

TCrGroupConditionNumber = integer;

TCrGroupOptionsNumber = integer;

TCrGroupSortFieldsNumber = integer;

TCrLogOnInfoTable = integer;

TCrParamFieldName = string;

TCrRangeNumber = integer;

TCrReportName = string;

TCrSectionFontSection = string;

TCrSectionFormatSection = string;

TCrSectionFormatFormulasSection = string;

TCrSectionHeightSection = string;

TCrSessionInfoTable = integer;

TCrSortFieldsNumber = integer;

TCrStoredProcParamName = string;

TCrSubreportName = string;

TCrTableNumber = integer;

TCrWinControl = TWinControl;


Types - See also
Related

Constants

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Constants

See also

Empty String

CrEmptyStr = 'EmptyStr';

CrwNull = 'EmptyStr';

Margins

PE_SM_DEFAULT = $8000;  {32768 in decimal}

Section

clUnchangedColor = PE_UNCHANGED_COLOR; {-2}


Constants - See also
Related

Types

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


TCrpeString

See also

Type

TCrpeString = class(TStringList)

Description

TCrpeString is the same as Delphi's TStringList, except the Put method defaults to Add if the subscript is one number larger than the number of strings in the StringList.  With a normal StringList, the following code would cause an error:

var

  slTemp : TStringList;

begin

  slTemp := TStringList.Create;

  slTemp[0] := 'The first line';

end;

The reason for the error is that we have attempted to access the first string in the stringlist, but the first string does not exist yet.  The proper way to do this would be:

var

  slTemp : TStringList;

begin

  slTemp := TStringList.Create;

  slTemp.Add('The first line');

end;

However, with the TCrpeString type, the first example would work as well as the second one.  Therefore, this is perfectly legal with the TCrpeString type:

var

  slTemp : TCrpeString;

begin

  slTemp := TCrpeString.Create;

  slTemp[0] := 'The first line';

end;

TCrpeString VCL Properties

Primarily, this type was created for the previous versions of the Crystal Reports VCL, where stringlists were used for almost every property that required multiple values or multiple lines, and where the subscript often represented the order of items in the Report.  We have decided to retain this type and continue using it in the new VCL, even though it's added functionality is not quite as necessary as it used to be.  The following properties all use the TCrpeString type:

Formulas	- Formula property

GroupSelection	- Formula property

Params	- Value property

Selection	- Formula property

SQL	- Query property

SummaryInfo	- Comments property

Using the TCrpeString

How do I pass values to the TCrpeString?  Well, you can use any method that is legal for a TStringList, as well as the subscript method outlined above:

var

  crList : TCrpeString;

begin

  crList := TCrpeString.Create;

  crList[0] := 'Subscript adds a new line if it doesn't already exist, or replaces the value in the line specified if the line already exists');

  crList.Text := 'Text treats the stringlist as one block of text';

  crList.SetText('SetText adds PChar strings to the List');

  crList.Add('Add adds one new line to the List');

  crList.Assign(Memo1.Lines); {Assign copies another stringlist into the TCrpeString}

  crList.Free;

end;


TCrpeString - See also
See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


About Section Names

See also

Explanation

Section Names in the Crystal Reports VCL are now the same as the shortened Section names used in the Crystal Reports Designer.  The following prefixes are used for the different possible sections:

RH	=  Report Header

PH	=  Page Header

GH	=  Group Header

D	=  Details

GF	=  Group Footer

PF	=  Page Footer

RF	=  Report Footer

Group Headers and Footers also have a number associated with the prefix, which specifies to which Group they belong, starting with the number 1 for the first Group.  So:

GH1	=  Group Header for Group 1

GF2	=  Group Footer for Group 2

etc.

If a Section has been divided into multiple Sub-Sections, these are specified by alphabetic letters going from a to z and then aa to zz, and so on.

GH1a	=  Group Header 1, sub-section a

GF2b	=  Group Footer 2, sub-section b

etc.

If the Retrieve method is used for the properties such as SectionFormat and AreaFormat the Section property will automatically be calculated and filled by the VCL.  If the manual Add/Delete methods are used, the Section will have to be assigned manually.

Limitations

The Crystal Reports Print Engine uses a numbering division of:

1000 for each main section

25 for each sub-section

0 to 24 for each Group

So:

1000 is used for the Report Header

2000 for the Page Header

3000 for the Group Header, etc.

Groups can be from 0 to 24, so:

Group Header 1 is 3000

Group Header 3 is 3002, etc.

Sub-sections are divided by 25, so:

Group Header 1a is 3000

Group Header 2b is 3026, etc.

This means a possible 40 divisions of 25 for each Section, since 40 * 25 = 1000.  Therefore the Print Engine cannot access more than 40 sub-sections at runtime.  Since the VCL uses the runtime Print Engine, it also has this limitation.  While this is not usually a problem with most Reports, the limit can be reached if a Report contains more than 40 Detail sections, for example.  In such cases, the VCL will only retrieve the first 40 sections.

SectionCode Numbering Example

Using the information spelled out above, a simple example of the Sections of a Report, with their corresponding Section Code numbers is illustrated below:

Area / Sections	Area / Section Numbers

Report Header	1000

Report Header a	1000

Report Header b	1025

Page Header	2000

Page Header a	2000

Page Header b	2025

Group Header 1	3000

Group Header 1a	3000

Group Header 1b	3025

Group Header 1c	3050

Group Header 2	3001

Group Header 2a	3001

Group Header 2b	3026

Group Header 2c	3051

Details	4000

Details a	4000

Details b	4025

Group Footer 2	5001

Group Footer 2a	5001

Group Footer 2b	5026

Group Footer 2c	5051

Group Footer 1	5000

Group Footer 1a	5000

Group Footer 1b	5025

Group Footer 1c	5050

Page Footer	7000

Page Footer a	7000

Page Footer b	7025

Report Footer	8000

Report Footer a	8000

Report Footer b	8025

StrToSectionCode/SectionCodeToStr

There are two functions included in the Crystal component: StrToSectionCode and SectionCodeToStr.  These functions are used internally by the component, but are public methods and so can be used by programmers.  Their purpose is to convert a Section name from one of the component's Section properties into a Print Engine Section code and back again.


About Section Names - See also
Related

AreaFormat

SectionFormat

SectionFont

SectionHeight

See also

Properties by Group

Methods by Group

Properties

Methods

Events

Back to Start


Utility Methods


AddBackSlash method

See also

Declaration

function AddBackSlash(const sPath: string): string;

Description

AddBackSlash takes a directory path as a parameter and makes sure that the last character is a backslash.

Example

uses UCrpeUtl...

var

  str1 : string;

begin

  str1 := 'c:\windows';

  str1 := AddBackSlash(str1);

  {str1 now looks like this: 'c:\windows\'}

end;


GetErrorNum method

See also

Declaration

function GetErrorNum(const sError: string): integer;

Description

GetErrorNum takes a VCL Error String Constant (which includes an error number and an error string), and extracts the Error Number, passing it back out as an integer.

See also Error Numbers & Strings.

Example

uses UCrpeUtl...

var

  int1 : string;

begin

  int1 := GetErrorNum(ECRPE_SUBSCRIPT);

  {int1 now looks like this: 116}

end;


GetErrorStr method

See also

Declaration

function GetErrorStr(const sError: string): string;

Description

GetErrorStr takes a VCL Error String Constant (which includes an error number and an error string), and extracts the Error String, passing it back out.

See also Error Numbers & Strings.

Example

uses UCrpeUtl...

var

  str1 : string;

begin

  str1 := GetErrorStr(ECRPE_SUBSCRIPT);

  {str1 now looks like this: 'Subscript out of range'}

end;


GetPathFromAlias method

See also

Declaration

function GetPathFromAlias(const sAlias: string; var sPath: string): boolean;

Description

GetPathFromAlias takes a BDE Alias name, and finds the database path specified for that particular Alias.  The path is passed back via the sPath variable.  If the call fails, the function returns False.

This function will be useful to those developers who use BDE Aliases to store path information, such as the directory that Reports are stored in.  When using the GetPathFromAlias function, be sure to format the BDE Alias name with colons on each side, ie:  ':MyAlias:'.  A standard pathname string with trailing backslash will be returned.

This function is used internally in the VCL when BDE Aliases are passed to the Tables.Path property.

Example

The following code illustrates the use of the GetPathFromAlias function to retrieve the path that the Reports are stored in:

uses UCrpeUtl...

var

  sPath: string;

begin

  sPath := GetPathFromAlias(':MyReportsAlias:');

  Crpe1.ReportName := sPath + 'Report1.rpt';

  Crpe1.Execute;

end;


GetStrFromRsc method

See also

Declaration

function GetStrFromRsc(RscNum: integer): string;

Description

GetStrFromRsc calls the Windows API LoadString function to obtain a Resource string from a Resource Number.  Note that the Resource file must be included in the Application or Unit file using the $R compiler directive:

{$R MYRESOURCE.RES}


GetToken method

See also

Declaration

function GetToken(var s: string; const sDelimiter: string): string;

Description

GetToken takes a delimited string and removes the part before the delimiter, passing it back as the result of the function.  The original delimited string will have the first delimited string and the delimiter removed.  For example, assuming a delimited time string: '12:22:33', the '12' would be passed back from the function and the time string would then look like this: '22:33'.  The code would look like this:

Example

uses UCrpeUtl...

procedure GetHour;

var

  sTimeString: string;

  sHour: string;

begin

  sTimeString := '12:22:33';

  sHour := GetToken(sTimeString, ':');

  ShowMessage(sHour);        {Displays '12'}

  ShowMessage(sTimeString);  {Displays '22:33'}

end;

The following code illustrates the use of the GetToken function to parse a date string (YYYY-MM-DD):

function GetDate(DateStr: string): TDateTime;

var

  wYear,

  wMonth,

  wDay : Word;

begin

  {Extract Year, Month, Day}

  wYear := StrToInt(Crpe1.GetToken(DateStr, '-'));

  {The DateStr now has MM-DD; wYear has YY}

  wMonth := StrToInt(Crpe1.GetToken(DateStr, '-'));

  {The DateStr now has DD; wMonth has MM}

  wDay := StrToInt(DateStr);

  Result := EncodeDate(wYear, wMonth, wDay);

end;


IsNumeric method

See also

Declaration

function IsNumeric(Value: string): boolean;

Description

IsNumeric checks each character of a given string to determine if all the characters are in the ASCII range that defines numerals (48 to 57).  If the characters are in the numeric range, the function result is True, otherwise it is False.

Example

uses UCrpeUtl...

var

  str1 : string;

begin

  str1 := '1.2a';

  if IsNumeric(str1) then

    ShowMessage('String is numeric')

  else

    ShowMessage('String is not numeric');

end;


IsStrEmpty method

See also

Declaration

function IsStrEmpty(const sValue: string): boolean;

Description

IsStrEmpty checks a given string to see if it's length (after trimming) is greater than zero.  If the length is zero, the result is True, otherwise it is False.

See also TruncStr.

Example

uses UCrpeUtl...

var

  str1 : string;

begin

str1 := '  ';

if IsStrEmpty(str1) then

  ShowMessage('str1 is empty!');

{str1 will be considered empty because spaces are ignored}

end;


StrToValueInfo method

See also

Declaration

function StrToValueInfo(const sValue: string; var ValueInfo: PEValueInfo): boolean;

Description

StrToValueInfo takes two parameters: a string parameter containing a certain value, and a PEValueInfo structure (see the CRDYNAMIC.PAS file for the definition of this structure).  The PEValueInfo structure must have the ValueType member set before being passed into this function.  The function then takes the string value, and according to the ValueType, converts it into the appropriate type and copies it to the appropriate member of the ValueInfo structure.

The ValueInfo structure is used when making Print Engine API calls to CRPE32.DLL.  Developers using the VCL should not normally need to use this structure or the StrToValueInfo method, as they are handled internally.


TruncStr method

See also

Declaration

function TruncStr(sValue: string): string;

Description

TruncStr takes a floating point value formatted as a string, and removes the decimal and any numbers after it.

See also IsStrEmpty method.

Example

uses UCrpeUtl...

var

  str1: string;

begin

  str1 := Crpe1.TruncStr('12.34');

  {str1 is now '12'}

end;


ValueInfoToStr method

See also

Declaration

function ValueInfoToStr(var ValueInfo: PEValueInfo): string;

Description

ValueInfoToStr takes a PEValueInfo structure (see the CRDYNAMIC.PAS file for the definition of this structure), and according to the ValueType, converts the appropriate member of the ValueInfo structure into a string and passes it back.

The PEValueInfo structure is used when making Print Engine API calls to CRPE32.DLL.  Developers using the VCL should not normally need to use this structure or the ValueInfoToStr method, as they are handled internally.


CrBooleanToStr method

See also

Declaration

function CrBooleanToStr(const bValue: boolean; ResultAsNum: boolean): string;

Description

CrBooleanToStr takes a boolean value and converts it to a string. If ResultAsNum is True, the string representation will be '1' or '0'.  If ResultAsNum is False, the string representation will be 'True' or 'False'.

See also CrStrToBoolean.

Example

uses UCrpeUtl...

var

  str1 : string;

begin

str1 := CrBooleanToStr(True, False);

{str1 is now 'True'}

str1 := CrBooleanToStr(True, True);

{str1 is now '1'}

end;


CrStrToBoolean method

See also

Declaration

function CrStrToBoolean(const sValue: string): boolean;

Description

CrStrToBoolean takes a string value and converts it to a boolean. The string value is assumed to be either in the format 'True/False', '1/0', or 'Y/N'.  If it is not in any of these formats, a False is returned by default.

See also CrBooleanToStr.

Example

uses UCrpeUtl...

var

  bTmp : boolean;

begin

  bTmp := CrStrToBoolean('Y');

  {bTmp is now set to True}

end;


CrFloatingToStr method

See also

Declaration

function CrFloatingToStr(const fValue: double): string;

Description

CrFloatingToStr takes a floating point number and returns a string representation of the number.  Delphi's FloatToStrF function is used in this method so that the Windows International Decimal symbol is preserved.

See also CrStrToFloating.

Example

uses UCrpeUtl...

var

  fValue : double;

  str1   : string;

begin

  fValue := 1.23;

  str1 := CrFloatingToStr(fValue);

  {str1 now looks like this: '1.23'}

end;


CrStrToFloating method

See also

Declaration

function CrStrToFloating(const sValue: string): double;

Description

CrStrToFloating takes a floating point value formatted as a string and returns a floating point value.

See also CrFloatingToStr.

Example

var

  str1 : string;

  dTmp : double;

begin

  str1 := '1.23';

  dTmp := CrStrToFloating(str1);

  {dTmp is now: 1.23}

end;


CrDateToStr method

See also

Declaration

function CrDateToStr(const dValue: TDateTime): string;

Description

CrDateToStr takes a Delphi DateTime variable and passes back a string formatted as 'yyyy,mm,dd'.

Example

uses UCrpeUtl...

var

  str1 : string;

begin

  str1 := CrDateToStr(Now);

  {str1 now looks something like this: '1999,10,18'}

end;

Related

CrDateTimeToStr

CrStrToDateTime

ExDateTimeStr

CrStrToDate

ExDateStr

CrTimeToStr

CrStrToTime

ExTimeStr


CrStrToDate method

See also

Declaration

function CrStrToDate(const sValue: string; var dValue: TDateTime): boolean;

Description

CrStrToDate takes a date value formatted as a string, and passes back a Delphi DateTime value in the dValue parameter.  If the conversion fails because the string is not formatted properly, a False is returned by the function.  The string is expected to be in the format 'yyyy,mm,dd'.

Example

uses UCrpeUtl...

var

  dValue: TDateTime;

begin

  if not CrStrToDate('1997,02,03', dValue) then

    ShowMessage('An error occured during conversion');

end;

Related

CrDateTimeToStr

CrStrToDateTime

ExDateTimeStr

CrDateToStr

ExDateStr

CrTimeToStr

CrStrToTime

ExTimeStr


ExDateStr method

See also

Declaration

function ExDateStr(sValue: string; var sYear, sMonth, sDay: string): boolean;

Description

ExDateStr takes a date value formatted as a string and passes out the Year, Month, and Day portions into the respective var variables.  If the extraction fails because the string is not formatted properly, the function returns False.  The string is expected to be in the format 'yyyy,mm,dd'.

Example

uses UCrpeUtl...

var

  sDate    : string;

  sY,sM,sD : string;

begin

  sDate := '1998,02,03';

  if ExDateStr(sDate, sY, sM, sD) then

    ShowMessage('Y/M/D strings extracted successfully!');

end;

{sY = '1998'; sM = '02'; sD = '03'}

Related

CrDateTimeToStr

CrStrToDateTime

ExDateTimeStr

CrDateToStr

CrStrToDate

CrTimeToStr

CrStrToTime

ExTimeStr


CrDateTimeToStr method

See also

Declaration

function CrDateTimeToStr(const dtValue: TDateTime; bMSec: boolean): string;

Description

CrDateTimeToStr takes a Delphi DateTime variable and returns a string.

•	If the bMSec parameter is True, the string date format will be: 'yyyy,mm,dd hh:nn:ss.xxx'.

•	If the bMSec parameter is False, the string date format will be: 'yyyy,mm,dd hh:nn:ss'.

Example

uses UCrpeUtl...

var

  str1: string;

begin

str1 := CrDateTimeToStr(Now, False);

{str1 now looks something like this: '1999,10,14 12:02:31'}

str1 := CrDateTimeToStr(Now, True);

{str1 now looks something like this: '1999,10,14 12:02:31.000'}

end;

Related

CrStrToDateTime

ExDateTimeStr

CrDateToStr

CrStrToDate

ExDateStr

CrTimeToStr

CrStrToTime

ExTimeStr


CrStrToDateTime method

See also

Declaration

function CrStrToDateTime(const sValue: string; var dtValue: TDateTime): boolean;

Description

CrStrToDateTime takes a datetime value formatted as a string, and passes back a Delphi DateTime value in the dtValue parameter.  If the conversion fails because the string is not formatted properly, a False is returned by the function.  The string is expected to be in the format 'yyyy,mm,dd hh:nn:ss', or 'yyyy,mm,dd hh:nn:ss.xxx' (includes milliseconds).

Example

uses UCrpeUtl...

var

  dtValue: TDateTime;

begin

  if not CrStrToDateTime('1997,02,03 12:22:23', dtValue) then

    ShowMessage('An error occured during conversion');

end;

Related

CrDateTimeToStr

ExDateTimeStr

CrDateToStr

CrStrToDate

ExDateStr

CrTimeToStr

CrStrToTime

ExTimeStr


ExDateTimeStr method

See also

Declaration

function ExDateTimeStr(sValue: string; var sYear, sMonth, sDay, sHour, sMin, sSec: string): boolean;

Description

ExDateTimeStr takes a string value formatted as datetime and returns the Year, Month, Day, Hour, Minute, and Second portions in their respective var variables.  If the function fails because the string is not formatted properly, it returns False.  The string is expected to be in the format: 'yyyy,mm,dd hh:nn:ss'.

Example

uses UCrpeUtl...

var

  sDateTime : string;

  sY,sM,sD,

  sH,sN,sS  : string;

begin

  sDateTime := '1998,02,03 12:22:23';

  if ExDateTimeStr(sDateTime, sY, sM, sD, sH, sN, sS) then

    ShowMessage('Y/M/D H/M/S strings extracted successfully!');

  {sY = '1998'; sM = '02'; sD = '03';

   sH = '12'; sN = '22'; sS = '23'}

end;

Related

CrDateTimeToStr

CrStrToDateTime

CrDateToStr

CrStrToDate

ExDateStr

CrTimeToStr

CrStrToTime

ExTimeStr


CrTimeToStr method

See also

Declaration

function CrTimeToStr(const tValue: TDateTime): string;

Description

CrTimeToStr takes a Delphi DateTime variable and returns the Time portion formatted as a string: 'hh:mm:ss'.

Example

uses UCrpeUtl...

var

  str1: string;

begin

  str1 := CrTimeToStr(Now);

  {str1 now looks something like this: '12:02:31'}

end;

Related

CrDateTimeToStr

CrStrToDateTime

ExDateTimeStr

CrDateToStr

CrStrToDate

ExDateStr

CrStrToTime

ExTimeStr


CrStrToTime method

See also

Declaration

function CrStrToTime(const sValue: string; var tValue: TDateTime): boolean;

Description

CrStrToTime takes a time value formatted as a string, and converts it to a Delphi DateTime value, which is passed into the tValue parameter.  If the function fails because the string is not formatted properly ('hh:mm:ss'), the function returns False.

Example

uses UCrpeUtl...

var

  sTime  : string;

  dtTime : TDateTime;

begin

  sTime := '12:01:23';

  if CrStrToTime(sTime, dtTime) then

    ShowMessage('String converted to Time successfully!');

end;

Related

CrDateTimeToStr

CrStrToDateTime

ExDateTimeStr

CrDateToStr

CrStrToDate

ExDateStr

CrTimeToStr

ExTimeStr


ExTimeStr method

See also

Declaration

function ExTimeStr(sValue: string; var sHour, sMin, sSec: string): boolean;

Description

ExTimeStr takes a time value formatted as a string, and returns the Hour, Minute, and Second portions in their respective var variables.   If the function fails because the string is not formatted properly ('hh:mm:ss'), it returns False.

Example

uses UCrpeUtl...

var

  sTime    : string;

  sH,sN,sS : string;

begin

  sTime := '12:22:23';

  if ExTimeStr(sTime, sH, sN, sS) then

    ShowMessage('H/M/S strings extracted successfully!');

end;

{sH = '12'; sN = '22'; sS = '23'}

Related

CrDateTimeToStr

CrStrToDateTime

ExDateTimeStr

CrDateToStr

CrStrToDate

ExDateStr

CrTimeToStr

CrStrToTime


SectionCodeToStr method

See also

Declaration

function SectionCodeToStr(const Value: smallint): string;

Description

SectionCodeToStr takes a Crystal Reports Print Engine Section Code number (1000, 2000, etc.) and converts it into a string representing the Report Section as seen in the Crystal Reports Designer ('RH', 'PH', etc.).  The StrToSectionCode function does the opposite conversion.

See About Section Names for more details on Print Engine Section Codes.

Example

uses UCrpeUtl...

var

  sTmp: string;

begin

  sTmp := SectionCodeToStr(3000);

  {sTmp will equal 'GH1a'}

end;


StrToSectionCode method

See also

Declaration

function StrToSectionCode(const Value: string; var nCode: Smallint): boolean;

Description

StrToSectionCode takes a Report Section string (as used in the VCL and the Crystal Reports Designer) and returns the equivalent Crystal Reports Print Engine Section Code number.  If the function fails because the string value is not a valid section code, the function returns False.

See About Section Names for more details on Print Engine Section Codes.

Example

uses UCrpeUtl...

var

  nTmp: Smallint;

begin

  if not StrToSectionCode('GH1a', nTmp) then

    ShowMessage('Failed!')

  else

    ShowMessage(IntToStr(nTmp));

    {nTmp will equal 3000}

end;


IndexInRange method

See also

Declaration

function IndexInRange(var nIndex: integer; nCount: integer): boolean;

Description

IndexInRange is used internally in the Crystal Reports VCL to determine if the item specified for a VCL class is within the range of items currently available for the class.  For example if there are 4 Formula items stored in the Formulas class of the VCL, and the user tries to access Formula 5, the IndexInRange function will return False.


IndexValid method

See also

Declaration

function IndexValid(nIndex: integer; nCount: integer): boolean;

Description

IndexValid is used internally in the Crystal Reports VCL to determine if the item specified for a VCL class is within the range of items currently available for the class.  For example if there are 4 Formula items stored in the Formulas class of the VCL, and the user tries to access Formula 5, the IndexValid function will return False.


CopyDevMode method

See also

Declaration

procedure CopyDevMode(var SourceDM: TDevMode; var DestinationDM: TDevMode);

Description

CopyDevMode takes two DevMode structures and copies the values from one to the other.


GetVersionInfo method

See also

Declaration

function GetVersionInfo(const Filename: string; const Key: string; var sVersion: string): DWord;

Description

GetVersionInfo obtains Version Information from a specified DLL or EXE.  The three parameters are:

Filename - The name of the DLL or EXE including the path.

Key - a string value representing the VersionInfo item to obtain.  Some examples of this are:

FileVersion

FileDescription

LegalCopyright

Comments

CompanyName

InternalName

OriginalFilename

ProductName

ProductVersion

sVersion - The variable that holds the returned string.

The DWord function result will either return zero (if the function succeeded) or a Windows Error Number (if the function failed).  Use Delphi's "SysErrorMessage (GetLastError)" to obtain a Windows API string explaining the error.

See also Version.

Example

uses UCrpeUtl...

var

  str1 : string;

begin

  str1 := GetVersionInfo('CRPE32.DLL', 'FileVersion');

  {str1 now looks something like this: '7.0.1.192'}

end;


RGBToColor method

See also

Declaration

function RGBToColor(ColorValue: COLORREF): TColor;

Description

RGBToColor takes an RGB number and converts it to a Delphi TColor type.


RTrimList method

See also

Declaration

function RTrimList(const sList: TStringList): string;

Description

RTrimList takes a Delphi StringList and trims off any trailing CR/LF (carriage return/linefeed) characters and returns the result as a string.