Select Report page to print from Dialog Form

I have made a report with 3 pages

Page1 (named order) of report is dynamic and grows depending on how much data
Page2 (named ccauth) of report is static text (like terms and conditions)
Page3 (named terms) of report is similar with more static text

I am trying to use dialog form with checkbox controls to determine which report page(s) are displayed when running report

I have looked in user manual and see how this works with controlling bands very nicely but when
I tried to do a small peice of code within onclick event to control the firing of the report pages I didnt have much luck

My Code:

procedure Button1Click(Sender: TfrxComponent); // This is OK button on Dialog Form
begin
if checkbox1.checked := True //Checkbox for page1 of report
then
Order.Visible := True
else
Order.Visible := False
if checkbox2.checked := True //Checkbox for page2 of report
then
ccauth.Visible := True
else
ccauth.Visible := False
if checkbox3.checked := True
then
terms.visible := True
else
terms.Visible := False
end;

Is this even possible ? Many thanks for your input and some direction on this.






Comments

  • Anu de DeusAnu de Deus Hampshire, UK
    edited December 2009
    Try a different approach (I didn't test this, so maybe it doesn't compile at all, it's just an idea that came to my mind):
    Check for the checkboxes at a later point, when the pages are going to be printed. My guess is that the control (pages) properties are being reset after the dialog executes.
    Page1.OnBeforePrint(sender);
    begin
      TFrxReportPage(sender).visible := checkbox1.checked;
    
    // probably all pages can be done here:
    // Page1.visible := checkbox1.checked;
    // Page2.visible := checkbox2.checked;
    // Page3.visible := checkbox3.checked;
    
    end;
    

    if that doesn't work try it in one of the Report events, like frxReport1.OnStartReport or frxReport1.OnReportPrint or frxReport1.OnRunDialogs
  • edited 9:07AM
    Use following code:
    frxReport1.Pages[1].Visible := CheckBox1.Checked;
    frxReport1.Pages[2].Visible := CheckBox2.Checked;
    frxReport1.Pages[3].Visible := CheckBox3.Checked;
    

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.