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

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

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.

Tables TableType property

Declaration

property TableType: TCrTableType;

Type

TCrTableType = (ttUnknown, ttStandard, ttSQL);

VCL Reference

674

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 (that is, 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.

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;

Tables Methods

Tables Add method

Declaration

procedure Add(TableNumber: TCrTableNumber);

Type

TCrTableNumber = integer;

VCL Reference

675

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:

1Add an item to the Tables object (you must specify the Table number).

2Fill the item's properties (Name, Path, etc.) with values.

3When 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.

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;

Tables Clear method

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 method 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 method:

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

Crpe1.Subreports[cnt];

Crpe1.Tables.Clear; end;

VCL Reference

676

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;

Tables CopyFrom method

Declaration

function CopyFrom(Source: TCrpeTables): boolean;

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.

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;

Tables Count method

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.

VCL Reference

677

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