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

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

GroupSortFields Properties

GroupSortFields DeleteGSF property, Page 387

GroupSortFields Direction property, Page 388

GroupSortFields Field property, Page 389

GroupSortFields Item property, Page 389

GroupSortFields ItemIndex property, Page 390

GroupSortFields Number property, Page 391

GroupSortFields Methods

GroupSortFields Add method, Page 391

GroupSortFields Clear method, Page 393

GroupSortFields CopyFrom method, Page 394

GroupSortFields Count method, Page 394

GroupSortFields Create method, Page 395

GroupSortFields Delete method, Page 395

GroupSortFields Destroy method, Page 396

GroupSortFields Retrieve method, Page 396

GroupSortFields Send method, Page 397

HasSavedData

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.

VCL Reference

47

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 to accomplish this.

Example

In the following example, if the report has saved data, it will be discarded:

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

Crpe1.DiscardSavedData := Crpe1.HasSavedData;

Crpe1.Output := toWindow;

Crpe1.Execute;

IsJobFinished

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.

Example

The following code example shows how to use the IsJobFinished property to determine if a Print Job is finished processing:

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.Output := toPrinter; Crpe1.Execute;

while not Crpe1.IsJobFinished do Application.ProcessMessages;

Crpe1.CloseJob;

VCL Reference

48

JobNumber

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 OnJobOpened event, Page 173 for more information.

Example

In this example, the current Print Job number will be shown:

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

Crpe1.OpenJob;

ShowMessage(IntToStr(Crpe1.JobNumber));

LastErrorNumber

Declaration

property LastErrorNumber: integer;

Description

The LastErrorNumber property is a run-time only property which holds the number of the last error that occurred 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.

VCL Reference

49

When a Print Engine error occurs, the component raises an Error exception, which would normally display a dialog box box with the Error Number and Error String displayed. By using the OnError event, this exception can be by-passed or a custom dialog box can be used instead. If the exception is by-passed, the internal procedure that the error occurred 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.

Example

This example shows how to display the LastErrorNumber and LastErrorString. Normally these would be handled by the internal Error exception:

Crpe1.ReportName := 'MyReport.rpt' Crpe1.Execute;

if Crpe1.LastErrorNumber > 0 then

ShowMessage('Error ' + IntToStr(Crpe1.LastErrorNumber) + ': ' + Crpe1.LastErrorString);

end;

LastErrorString

Declaration

property LastErrorString: string;

Description

The LastErrorString property is a run-time only property which holds the text message of the last error that occurred 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 box can be used instead. If the exception is by-passed, the internal procedure that the error occurred 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.

VCL Reference

50

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