5 Replies Latest reply: May 15, 2014 9:57 AM by RalphB _ RSS

    Automated Import Into MS Access Table

    gpotenza _

      Previously I was using vba modules in MS Access to extract data using Monarch and exporting into a text file (from Monarch).


      Code follows:


      Is there a way to do the same thing only skip exporting as a text file and send the data directly from Monarch to a predefined Access table?



      VBA Code

      Public Function MonarchImport(strFile As String, strExp As String)


      Dim MonarchObj As Object

      Dim OpenFile, openmod, t As Boolean


      Set MonarchObj = CreateObject("Monarch32")

      OpenFile = MonarchObj.SetLogFile("C:Program FilesMonarchReports", False)

      OpenFile = MonarchObj.SetProjectFile(strFile)

      If OpenFile Then

      'I am thinking something needs to change here but I am not sure to what   

      MonarchObj.ExportTable (strExp)


      End If



      Set MonarchObj = Nothing


      End Function

        • Automated Import Into MS Access Table
          RalphB _



          Have you tried using the JetExportTable(strExportfile,strTableName,integerAppendFlag) in place of the ExportTable?  With that you can designate the database and table within the database in which to export to.


          I have some scripts that I export 2 different tables to the same MS database and have had no problems.


          Check out the Programmers Guide for more details.



          • Automated Import Into MS Access Table
            gpotenza _

            I have been trying that but am confused as to what the strExportTable represents.  Is it the name of the database?  Is it the name of the project file I am using in Monarch?  Can you clarify that for me?

            • Automated Import Into MS Access Table
              RalphB _

              It is the path and file name of the database or spreadsheet you are exporting to.  For example "C:MonarchDatabases     est.mdb".  The strTableName is the name of the table you want to use.  The AppendFlag integer will tell it if you want to: 0 overwrite,1 new table or sheet or 2 append to existing table or sheet.

              • Automated Import Into MS Access Table
                gpotenza _

                I'm receiving an error:  "Object Doesn't Support this Property or Method".  Is there a certain version of Monarch needed to support this or a certain version of Access?


                I am using Monarch 6 and Access 97...

                • Automated Import Into MS Access Table
                  RalphB _

                  You need th Monarch Pro versions to use the jetexport functions.


                  If you don't have it and are planning on doing more exports of this type the upgrade to the pro version would be well worth the investment.  Besides the pro versions offer much more functionality with the database joins etc.