Information about complex report

Posted by: jluis-dd on 4 August 2017, 2:37 pm EST

  • Posted 4 August 2017, 2:37 pm EST

       Hi there!

       I got long time using AR, in there, I created a lot of applications like mail merge, a postal label's editor, a end user report designer and managing reporting in runtime (my favorite). But there were always a little doubt, and guess its time to solve it [:D].
       I have to make a complex report, with a lot of pages, but, every single page is diferent from the others. My report is completly dinamyc. In there Im thinking in use subreports for manage the different kind of information, but as I said, I select trough code wich subreport gonna be added to the main report.
       But I dont know how to manage the matter of the page's size: I used to put everything in the details section of the main report, but all the information displayed was of the kind of bound and unbound report. In this new project, I need to add all the information on run-time, that mean that only the subreports uses the data connections.
       Do you have an example or a sample for doing something like this?

    JLuis
     
  • Replied 4 August 2017, 2:37 pm EST

    I have an instance were the user can select from 1 to 20 different reports for query set in any combination they so choose.

    How I approached the problem was to give them a display of 20 checkboxes on a form and single view command button. The user will select which report(s) they want to see via the checkboxes, then hit the view button. If a checkbox is checked I fire a report or series of reports and add their page(s) to a 'Master' report. Once all the checkbox selections are processed, the completed 'Master' report is displayed.

    I don't believe you can mix orientation, portrait and landscape, or page size, legal and letter for example, but other than that there isn't much limit on what you can piece together.
  • Replied 4 August 2017, 2:37 pm EST

    That is an excellent approach to the problem. The other alternative is adding each page and drawing the text you need on each page. The problem is that is basically like creating your own layout engine and if this is a large report, you'd be better off just toggling subreports like WSmith said. Mixing paper orientations is ok and can be done in the PageStart event but it lacks professionalism. Mixing papersizes will result in a very confused printer and I don't recommend it.

  • Replied 4 August 2017, 2:37 pm EST

    In light of Brandon's post I should revise what I said to be more clear. "I don't believe you 'should' mix...", just because you can programatically, doesn't mean you should for various reasons, user friendly, printer confusion, processor or nextwork load, etc.

    Here is the basic code that would run what I explained above.

    Private mrptMaster as ActiveReport
    Private mrptData as ActiveReport

    Private Sub CommandView_Click()
       Dim intI as Integer
       Set mrptMaster = New ActiveReport
       
       For intI = 0 to chkReports.UBound
          If chkReports(intI).Value = vbChecked Then
             Select Case chkReports(intI).Tag
                Case "Alpha"
                   Set mrptData = New rptAlpha
                   Call FireReport

                Case "Beta"
                   Set mrptData = New rptBeta
                   rptBeta.DataControl1.Source = StringBeta1
                   Call FireReport

                   Set mprtData = New rptBeta
                   rptBeta.DataControl1.Source = StringBeta2
                   Call FireReport

                Case "Gamma"
                   etc....
             End Select  
          End If 
       Next intI

       set mrptData = Nothing
       mrptMaster.Show
    End Sub

    Private Sub FireReport()
       Dim intP as Integer

       mrptData.Run False
       For intP = (mrptData.Pages.Count-1) to 0 Step -1
          mrptMaster.Pages.Insert 0, mrptData.Pages.Item(intP)
       Next intP
       mrptMaster.Pages.Commit
    End Sub
  • Replied 4 August 2017, 2:37 pm EST

       In fact, thats what I do on my App. Got a list with checkboxes.
       The problem for me is the way it manages the page breaks.
      
       Lets put it this way: The user click all the checkboxes (20), so in run time I add all the 20 subreports in the Details section of the main report.

       When I run the report, does it will automatically arange the subreports in the pages? how can I setup the subrepots to manage it?

       About mixing landscape and portrait on my report. It is necesary due the kind of subreports, but thats no a problem.

       Hope you can help me, because its a concept I cant really understand Embarrassedยก
  • Replied 4 August 2017, 2:37 pm EST

       Its a good Idea, but some or my subreports are very very small, like 2" x 2" square.
       Then, sometimes I just cant insert pages because I got to insert like 20 subreports(very smalls) and there gonna be 2 pages at last.

       So, what do you recomdend?
  • Replied 4 August 2017, 2:37 pm EST

    Well I'll just say this, when you said 'complex' you meant complex!

    Idea #2
    Right now I am thinking you will want a section for each subreport. Assuming that each subreport will fire once and complete it's entire run, i.e. no grouping, I would probably put in 10-20 GroupHeader/Footers (dunno if you can use the footer like this or if it will have to be headers only), unbound of course, and put one subreport object per. So basically nothing in the details section. If the user selects a check then you would make that section visible and set it's subreport object, if no checkbox then visibility would be false and subreport object set equal to nothing.

    I think this will give you enough flexability, you should be able to statically/design time setup each GroupHeader/Footer to match what it's specific subreport needs, page breaks, height, etc, other than page orientation, probably have to have a select statement or something in your pagestart for that. If you grouped all your landscapes together at the beginning or end, probably wouldn't be too big of a deal.

    I have done a bit of section switching on/off in the past, I even have one with a subreport, but nothing on this scale. The concept worked for me, so it is worth a shot for you I think.
  • Replied 4 August 2017, 2:37 pm EST

    Hmmmm....I guess the idea machine is in high gear right now. Here is another proposal.

    Idea #3
    You have your form with 20 checkboxes. User makes their selection. Build yourself an array of those selections. In other words, if the user selected checkboxes 1, 4, and 5 setup a one dimension array with three items with values like 1, 4, and 5 (could use a text key or enumeration too).

    Setup & Design your 20 subreports as normal.

    Setup an unbound 'Master' report with whatever report/page header/footer information you need and in the detail section setup one subreport object. Feed this unbound 'Master' your array from the form. On each iteration, you would reset the subreport object to whichever one of the 20 subs it indicated. There would need to be code to set your page breaks, orientation, left values if you wanted the 2x2 sub centered and the following 1x10 left aligned, etc.

    I like this idea more than the #2 as it follows database and recordset concepts.
  • Replied 4 August 2017, 2:37 pm EST

    Both of my ideas, #2 and #3, assume you are going to fire the subreports in sequence one right after the other, top to bottom. You can set your left values to get things centered. Meaning you will have output more or less like this.

     ----------
    |   Sub1   |
    | S u b 2  |
    |Sub 3     |
    |          |
     ----------
     ---------------
    |Sub 4          |
    |      Sub5     |
    |etc.           |
     ---------------



    If however you are trying to place subreports side by side (like below) as well as top to bottom, neither of my ideas would work as stated. 

     ----------
    |   Sub1   |
    | S u b 2  |
    |Sub3 Sub4 |
    |Sub4 Sub5 |
     ----------
     ---------------
    |  S  u  b  6   |
    |Sub7 Sub8 Sub9 |
    |etc.           |
     ---------------


    Though I think you could take the idea #3 and introduce another level of reports, in other words if the user selects option 1 and/or 2, they get sub1_2 which itself consists of two subreports (Grandchildren).

    Master
     - Sub1_2
     -- GC1 - GC2
     - Sub3
     - Sub4
     - Sub567
     -- GC5 - GC6
            - GC7
     - etc.


    Plenty of food for thought at least.
  • Replied 4 August 2017, 2:37 pm EST

    Thats a great IDEA!!!!!!

    let me try it and I will let you know the results.

    tnx a lot! [:D]

    jluis
  • Replied 4 August 2017, 2:37 pm EST

    The way I am doing it, I run up to 20 seperate full reports, and insert the returned pages into the 'Master' report. The 'Master' report is really not a report at all, just an empty container which I fill up one full page at a time. If the user selected all 20 then there would be at least 20 pages on the 'Master' report, more if one of the reports returned more than a single page of reported data.

    Example, the user checks boxes 1, 2, and 3 and then clicks view.
    - Report 1 is run, returning one page. One page is inserted into the Master. Master page count is one.
    - Report 2 is run, returning three pages. Three pages are inserted into the Master. Master page count is now four.
    - Report 3 is run, returning a single page. One page is inserted into the Master. Master page count is five.
    - Reports 4-20 are NOT run as their respecitve checkboxes were not selected.
    - Master report is displayed.
    --- Page 1 was originally Report 3's page 1
    --- Page 2 was originally Report 2's page 1
    --- Page 3 was originally Report 2's page 2
    --- Page 4 was originally Report 2's page 3
    --- Page 5 was originally Report 1's page 1

    If pages need to be displayed in a certain order, you can reverse looping, the above layout is how my basic code is setup as I am not picky about which report is displayed first as long as it's pages are in the proper sequence.
Need extra support?

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

Learn More

Forum Channels