Close Report if no data is returned

AndreAndre South Africa
edited 7:34AM in FastReport 4.0
Hi

I'm using an internal IBXQuery. When the reports starts a Dialog is displayed with two date combo boxes. The start and end date is selected from the drop downs. The report then returns the records between the two selected dates. If there are no records the message is displayed. But the report still shows after setting the page.visible := false,

How can I close the report when there is no data returned in the query ?
procedure Button1OnClick(Sender: TfrxComponent);
begin
  IBXQuery1.Close;                                  
  IBXQuery1.ParamByName('StartDT').Value := datetostr(StartDate.Date);
  IBXQuery1.ParamByName('EndDT').Value := datetostr(EndDate.Date);
  IBXQuery1.Open;
end;

procedure Page1OnBeforePrint(Sender: TfrxComponent);
begin
    if IBXQuery1.RecordCount = 0 then
  begin
    ShowMessage('Nothing to Print');
    Page1.Visible := False;                                                                    
  end;  
end;

Comments

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.