How to stop report on no data
I am trying to show a message and stop a report if there is no data to show.
In the report I can see, and use fields from the TfxDBDataset (called frxDBDatasetNextStepsByDept).
I have the OBP event as follows
However I get an undefined identifier error on frxDBDatasetNextStepsByDept. The same happens if I use the TClientDataSet that it is connected to or if I put in the form name as well
ie Frm_NextStepsReports.frxDBDatasetNextStepsByDept
The report uses the following chain of components to get its data from a SQLite3 database.
SQLite Database -> DISQlite3UniDirQuery (called QryNextStepsByDept) -> TDataSetProvider (called dspNextStepsByDept) ->TClientDataSet (called cdsNextStepsByDept) ->TfxDBDataset (called frxDBDatasetNextStepsByDept) ->TfrxReport . They are on a delphi form called Frm_NextStepsReports
What is the correct syntax to do it?
Is there even an 'OnNoData' event for a report hidden away somewhere [img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> Howard[/img]
In the report I can see, and use fields from the TfxDBDataset (called frxDBDatasetNextStepsByDept).
I have the OBP event as follows
procedure Page1OnBeforePrint(Sender: TfrxComponent);
begin
if frxDBDatasetNextStepsByDept.RecordCount = 0 then //<--this uses the TfxDBDataset
begin
ShowMessage('No data is available for this report');
engine.stopreport;
end;
end;
However I get an undefined identifier error on frxDBDatasetNextStepsByDept. The same happens if I use the TClientDataSet that it is connected to or if I put in the form name as well
ie Frm_NextStepsReports.frxDBDatasetNextStepsByDept
The report uses the following chain of components to get its data from a SQLite3 database.
SQLite Database -> DISQlite3UniDirQuery (called QryNextStepsByDept) -> TDataSetProvider (called dspNextStepsByDept) ->TClientDataSet (called cdsNextStepsByDept) ->TfxDBDataset (called frxDBDatasetNextStepsByDept) ->TfrxReport . They are on a delphi form called Frm_NextStepsReports
What is the correct syntax to do it?
Is there even an 'OnNoData' event for a report hidden away somewhere [img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> Howard[/img]
Comments
Thank you, that seemed to work to display the message (using the '<--this uses the TfxDBDataset' line). However the report is still left open with just a grey background.
Is it possible to also close the report and return to my program - without clicking the close button.
OK, Thank you.