Dynamically create summary fields

Posted by: blackriver on 4 August 2017, 3:18 pm EST

  • Posted 4 August 2017, 3:18 pm EST

    I can dynamically create Labels(in PageHeader section) and Fields(in Details Section).I can also dynamically populate fields with values from database.I can also check if a certain fields contains a numeric value and set the OutputFormat accordingly.
    But now I would like to know how to add a certain number of summary fields to PageFooter section depending on how many numeric fields there are in Details section.
    For example;
    If I have Price and Value in Details,I'd like to have 2 summary fields in PageFooter(PriceTotal,ValueTotal).

    Where to I start?

  • Replied 4 August 2017, 3:18 pm EST

    And after a cup of coffee and some rest I managed to solve my problem.It was quite simple.Just added a GroupHeader and Footer insted of PageHeader and Footer.Works like a charm!
    If anyone wants to see the code I used,be sure to post here.Maybe you can improve my work.

    Bye for now!

  • Replied 4 August 2017, 3:18 pm EST

    this is just great:) could you please tell me how i can dynamically add columns in a table depending on how many parameters the user enters. thanks
  • Replied 4 August 2017, 3:18 pm EST

    If you want to add X number of fields at run-time to your report, you should use something like this:

    Dim rptMain as ActiveReport1
    Dim oCtrl as Object

         Set rptMain = New ActiveReport1
         'Set the datasource for your report
         Set oCtrl = rptMain.Sections("Detail").Controls.Add("DDActiveReports2.DataControl")

         oCtrl.ConnectionString = YourConnectionString
         oCtrl.Recordset = YourRecordSet

    'Set up Sections for your report
    'set up group header
        rptMain.Sections.Add "Group", 1, ddSTGroupHeader, 400
        rptMain.Sections.Add "foot", 3, ddSTGroupFooter, 500
        rptMain.Sections("Group").Visible = True
        rptMain.Sections("Group").GrpKeepTogether = True
        rptMain.Sections("Group").KeepTogether = True
        rptMain.Sections("Group").BackStyle = 0
        rptMain.Sections("Group").Repeat = 1
        rptMain.Sections("Group").CanGrow = True
    'set up group footer
        rptMain.Sections("foot").Visible = True
        rptMain.Sections("foot").BackStyle = 0
        rptMain.Sections("foot").KeepTogether = True
        rptMain.Sections("foot").CanGrow = True
        'setting up the detail section

        rptMain.Detail.Height = 300
        rptMain.Detail.BackStyle = 0 '1 = normal 0 = transparent
        rptMain.Detail.BackColor = &HC0C0C0
        rptMain.Detail.ColumnCount = 1
        rptMain.Detail.KeepTogether = True
        rptMain.Detail.CanGrow = True
        rptMain.Detail.Visible = True

    Now that you have everything set up, you can add Labels,Fields,Lines and everything else to your report. I'm not familiar with your exact requirements, but if you are working with records from RecordSet, then you should keep in mind that every Field control needs to have its DataField set to corresponding FieldName from the recordSet.

    If you have more question, I would be glad to help!
  • Replied 4 August 2017, 3:18 pm EST

    thankyou so much for all your help
  • Replied 4 August 2017, 3:18 pm EST

    will this only work in ActiveReports? or will it work in dataDynamics reports too?
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels