Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
163
Добавлен:
11.05.2015
Размер:
4.73 Mб
Скачать

SQL Send method

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.

It is strongly recommended 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.

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;

Subreports Properties

Subreports Item property

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 itself, so the Subreports properties can be used right after the subscript: ShowMessage(Subreports[2].Section);

VCL Reference

650

Example

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

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.Subreports.Retrieve;

{Set Subreports object to the 2nd subreport} Crpe1.Subreports.Item[2];

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.Subreports.Retrieve;

{Set Subreports object to the 2nd subreport} Crpe1.Subreports[2];

Subreports ItemIndex property

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.

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));

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];

Subreports Name property

Declaration

property Name: TCrSubreportName;

VCL Reference

651

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.

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];

VCL Reference

652

Subreports NLinks property

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 independent of the formatting of the main Report.

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');

Subreports OnDemand property

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.

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');

VCL Reference

653

Соседние файлы в папке crystal