5 Replies Latest reply: May 15, 2014 9:56 AM by Nick Osdale-Popa RSS

    PrintTable

    MorseB _

      What do I need to correct in order for the table view to print?

       

      Private Sub cmd_100_400_Balance_Click()

       

          Dim monarchobj As Object

          Dim openfile As Boolean

          Dim openmod As Boolean

          Dim t As Boolean

          Dim expfile As Boolean

          Dim stringTableName As String

          Dim stDocName As String

          Dim strname As String

          Dim stappname As String

          Dim db As Database

          Set db = CurrentDb

          Dim ImportRecordSet As Recordset

           

       

      '02-16-07 changed message

          MsgBox "Monarch will now start and print report."

           

          'If Monarch is currently active GetObject() will use Monarch. If it is not currently active CreateObject()will open Monarch

       

           Set monarchobj = GetObject("", "Monarch32")

           If monarchobj Is Nothing Then

           Set monarchobj = CreateObject("Monarch32")

           End If

       

           t = monarchobj.setlogfile("C:MonTempMPrg_G5.log", False)

       

           openfile = monarchobj.SetReportFile("Treas_recpt_nt2dImportDataDownload107_JPMC_Access_Dailydailyfile.dat", False)

           

          'open Monarch module

           If openfile = True Then

           openmod = monarchobj.SetModelFile("Treas_recpt_nt2dReconWinMonarchX-ModsJPMC_Access_Daily-bal_$_Cnt.xmod")

           

          'set Monarch filter

               If openmod = True Then

                  monarchobj.CurrentFilter = "100_400"

                  monarch.obj.PrintTable (True)

              End If

               

              monarchobj.CloseAllDocuments

       

           End If

       

           monarchobj.CloseAllDocuments

           monarchobj.Exit

       

      End Sub

        • PrintTable
          Data Kruncher

          Hi Beth,

           

          I think this as simple as a typo this time.

           

          Change your  [font="courier"]monarch.obj.PrintTable (True)  /font[/quote]to [font="courier"]monarchobj.PrintTable (True)[/font][/quote]without the first period.

           

          There was an error posted in 2004 relating to using PrintTable with database sources, but that doesn't seem to be the case here.

           

          HTH,

          Kruncher

          • PrintTable
            MorseB _

            Kruncher,

             

            Corrected the period.  However, it still did not run.

             

            So I tried using summary and getting no where.  The report comes up but I never it see it go to table or summary view.

             

            Revised code below:

             

            Private Sub cmd_100_400_Balance_Click()

             

                Dim monarchobj As Object

                Dim openfile As Boolean

                Dim openmod As Boolean

                Dim t As Boolean

                Dim expfile As Boolean

                Dim stringTableName As String

                Dim stDocName As String

                Dim strname As String

                Dim stappname As String

                Dim db As Database

                Set db = CurrentDb

                Dim ImportRecordSet As Recordset

                 

             

            '02-16-07 changed message

                MsgBox "Monarch will now start and print 100 & 400 balancing report."

                 

                'If Monarch is currently active GetObject() will use Monarch. If it is not currently active CreateObject()will open Monarch

             

                 Set monarchobj = GetObject("", "Monarch32")

                    If monarchobj Is Nothing Then

                        Set monarchobj = CreateObject("Monarch32")

                    End If

             

                 t = monarchobj.setlogfile("C:MonTempMPrg_G5.log", False)

             

                 openfile = monarchobj.SetReportFile("Treas_recpt_nt2dImportDataDownload107_JPMC_Access_Dailydailyfile.dat", False)

                 

                'open Monarch module

                 If openfile = True Then

                    openmod = monarchobj.SetModelFile("Treas_recpt_nt2dReconWinMonarchX-ModsJPMC_Access_Daily-bal_$_Cnt.xmod")

                 

                'set Monarch filter

                    If openmod = True Then

                        monarchobj.CurrentFilter = "100_400"

                        monarchobj.CurrentSummary = "100_400"

                        monarchobj.PrintSummary (True)

                       'monarchobj.PrintTable (True)

                    End If

                     

                    monarchobj.CloseAllDocuments

             

                 End If

             

                 monarchobj.CloseAllDocuments

                 monarchobj.Exit

             

            End Sub

            • PrintTable
              Nick Osdale-Popa

              With automation, the default view is the Report Window, to force either the Table Window or the Summary Window use the following code:

               

              'Table Window

              monarchobj.SetView("T")

               

              'Summary Window

              monarchobj.SetView("S")

               

              'To explicitly state the Report Window

              monarchobj.SetView("R")

               

              Hope that helps!

              • PrintTable
                Data Kruncher

                Hi Nick,

                 

                Beth PM'd me the other day and indicated that there was an error in the model file path, and that was the only error. All was well when the path was corrected.

                 

                Sorry, forgot to post back here.

                 

                This is a good example of why you should always use an ELSE when checking the success or failure of operations. The SetModelFile failed and the program just silently carried on to close Monarch.

                 

                Kruncher

                • PrintTable
                  Nick Osdale-Popa

                  Actually, I check if the Open has failed and raise an error as such:

                   

                  [font="courier"]        OpenFile = mapMonarch.SetReportFile(sReportFile, True)

                   

                         'Raise Error if File Open failed

                          If OpenFile = False Then

                               sProblem = "Error Opening File: " & sReportFile

                              Err.Raise vbObject + ReportErr, "Monarch", sProblem

                          End If[/font][/quote]But that's just me.