Merging X amount of reports into one to view

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

  • Posted 4 August 2017, 3:18 pm EST

    Hey all, i am looking for a way to merge a few reports into one for viewing. Is there any type of merge for AR2?



    This is the code i am using to loop through them and print them out currently:



    Do Until X = theCount

    connDB

    Set rst = New ADODB.Recordset

    strSQL = "SELECT id, theCode FROM jusers WHERE theCode = '" & theNames(X) & "'"

    MM.thePrintType = "eodd"



    With rst

    .Source = strSQL

    .ActiveConnection = conn

    .CursorType = adOpenDynamic

    .LockType = adLockOptimistic

    .Open



    arRec.theUID = !theCode

    arRec.Run

    arRec.Printer.DeviceName = MM.thePrnter

    arRec.Printer.DisplayProgressDialog = False

    Call arRec.PrintReport(False)

    Unload arRec

    Set arRec = Nothing



    .Close

    Set rst = Nothing

    conn.Close

    End With

    X = X + 1

    Loop



    Right now that just prints off however many sheets it needs too per report. However, what i am wanting to do is combine all that into one report so the user can see it all without having to print out multiply copies of the report(s) in order to see them all.



    Any help would be great, thanks!



    David
  • Replied 4 August 2017, 3:18 pm EST

    Thanks for the reply but it doesnt seem to be working for me. This is the code i am using



    Do Until X = theCount

    connDB

    Set rst = New ADODB.Recordset

    strSQL = "SELECT id, theCode FROM jusers WHERE theCode = '" & theNames(X) & "'"

    MM.thePrintType = "eodd"



    With rst

    .Source = strSQL

    .ActiveConnection = conn

    .CursorType = adOpenDynamic

    .LockType = adLockOptimistic

    .Open



    MM.theEODAll = False

    MM.thePrintType = "eoddd"



    If MM.isTesting = True Then

    arRec.theUID = !theCode

    arRec.Run



    For intP = 0 To arRec.Pages.Count - 1

    arRec.Pages.Insert arRec.Pages.Count, arRec.Pages(intP)

    Next intP

    arRec.Pages.Commit

    Else

    arRec.theUID = !theCode

    arRec.show

    End If



    .Close

    Set rst = Nothing

    conn.Close

    End With

    X = X + 1

    Loop



    arRec.show



    X loops twice since i have two reports to print out which each has one page. But the output on arRed.show shows 4 pages of the same report.



    David
  • Replied 4 August 2017, 3:18 pm EST

    I'd really like to resolve this problem :o)



    David
  • Replied 4 August 2017, 3:18 pm EST

    Really? no help to solve this?



    David
  • Replied 4 August 2017, 3:18 pm EST

    Still looking to find the answer to this question...



    David
  • Replied 4 August 2017, 3:18 pm EST

    Hello,

    You may use code as following to merge two different reports. They have to be run individually first to generate the pages collection.

    For intP = 0 To rptFrom.Pages.Count - 1
      
    rptInto.Pages.Insert rptInto.Pages.Count, rptFrom.Pages(intP)
    Next
    intP
    rptInto.Pages.Commit

    Regards,
    Prantik
  • Replied 4 August 2017, 3:18 pm EST

    Ok, i made some changes to the code but i still get duplicates????



    Do Until X = theCount - 1

    connDB

    Set rst = New ADODB.Recordset

    strSQL = "SELECT id, theCode FROM jusers WHERE theCode = '" & theNames(X) & "'"

    MM.thePrintType = "eodd"



    With rst

    .Source = strSQL

    .ActiveConnection = conn

    .CursorType = adOpenDynamic

    .LockType = adLockOptimistic

    .Open



    MM.theEODAll = False

    MM.thePrintType = "eoddd"



    If MM.isTesting = True Then

    arRec.theUID = !theCode

    arRec.Run



    For intP = 0 To arRec.Pages.Count - 1

    arRec.Pages.Insert arRec.Pages.Count, arRec.Pages(0)

    'MsgBox theNames(X)

    Next intP

    arRec.Pages.Commit

    DoEvents

    Else

    arRec.theUID = !theCode

    arRec.show

    End If



    .Close

    Set rst = Nothing

    conn.Close

    End With

    X = X + 1



    If X <> theCount Then

    'Unload arRec

    DoEvents

    End If

    Loop

    arRec.show



    It doesn't seem to close the first report after it loops the first time. A breakpoint on arRec.Pages.Commit only breaks once instead of twice. But if i put "unload arRed" and "set arRec = nothing" after "arRec.Pages.Commit" then it does break twice on "arRec.Pages.Commit" but when it finishes the loop and runs the "arRed.show" it doesn't have anything to show?



    David
  • Replied 4 August 2017, 3:18 pm EST

    Fixed.



    Do Until X = theCount - 1

    connDB

    Set rst = New ADODB.Recordset

    strSQL = "SELECT id, theCode FROM jusers WHERE theCode = '" & theNames(X) & "'"

    MM.thePrintType = "eodd"



    With rst

    .Source = strSQL

    .ActiveConnection = conn

    .CursorType = adOpenDynamic

    .LockType = adLockOptimistic

    .Open



    arRec.theUID = !theCode

    arRec.Run



    For intP = 0 To arRec.Pages.Count - 1

    BlankReport.Pages.Insert BlankReport.Pages.Count, arRec.Pages(0)

    Next intP

    BlankReport.Pages.Commit

    DoEvents



    .Close

    Set rst = Nothing

    conn.Close

    End With

    X = X + 1

    Loop



    BlankReport.show



    David
Need extra support?

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

Learn More

Forum Channels