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

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.

Records Methods

Records Printed method, Page 514

Records Read method, Page 514

Records Selected method, Page 515

ReportName

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. However, it can not be accessed via VCL code.

VCL Reference

85

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;

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;

VCL Reference

86

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