Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to reference MS Access 2016 for use with DoCmd, etc.

How to reference MS Access 2016 for use with DoCmd, etc.

Scheduled Pinned Locked Moved Visual Basic
questioncomlinuxhelptutorial
9 Posts 4 Posters 11 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Johan Hakkesteegt
    wrote on last edited by
    #1

    Hi, I have a couple of windows applications that use MS Access to print reports. They were built on MS Access 2007, and worked fine until I was forced to upgrade to Office365 and thus MS Access 2016. Unfortunately (apparently) Office365's version of Office 2016 does not allow you to have other Office versions installed, so I had to remove my Access 2007 version. The simplified version of my code that worked fine until now:

    Dim oAccess As Access.Application
    Dim x As Long
    AccessExecutablePath = New FileInfo("C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE").FullName
    x = Shell(AccessExecutablePath & " " & Chr(34) & DatabasePath & Chr(34) & " /runtime", AppWinStyle.MinimizedNoFocus)
    oAccess = New Access.Application
    oAccess = GetObject(DatabasePath)
    oAccess.PrintReport("Some_Report_Saved_In_MSACCESS")

    Apparently when you install Office 2016, it no longer has the necessary interop driver for Access, and the code no longer works. However, all microsoft's (I suppose outdated) documentation still says to use the code above. Here is my question: Has anyone else faced this issue, and more importantly can anyone suggest a solution, or another method to interact with the Access client? Regards, Johan

    My advice is free, and you may get what you paid for.

    Richard DeemingR A 2 Replies Last reply
    0
    • J Johan Hakkesteegt

      Hi, I have a couple of windows applications that use MS Access to print reports. They were built on MS Access 2007, and worked fine until I was forced to upgrade to Office365 and thus MS Access 2016. Unfortunately (apparently) Office365's version of Office 2016 does not allow you to have other Office versions installed, so I had to remove my Access 2007 version. The simplified version of my code that worked fine until now:

      Dim oAccess As Access.Application
      Dim x As Long
      AccessExecutablePath = New FileInfo("C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE").FullName
      x = Shell(AccessExecutablePath & " " & Chr(34) & DatabasePath & Chr(34) & " /runtime", AppWinStyle.MinimizedNoFocus)
      oAccess = New Access.Application
      oAccess = GetObject(DatabasePath)
      oAccess.PrintReport("Some_Report_Saved_In_MSACCESS")

      Apparently when you install Office 2016, it no longer has the necessary interop driver for Access, and the code no longer works. However, all microsoft's (I suppose outdated) documentation still says to use the code above. Here is my question: Has anyone else faced this issue, and more importantly can anyone suggest a solution, or another method to interact with the Access client? Regards, Johan

      My advice is free, and you may get what you paid for.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Have you tried the code from this MSKB article[^]?


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      J 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Have you tried the code from this MSKB article[^]?


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        J Offline
        J Offline
        Johan Hakkesteegt
        wrote on last edited by
        #3

        Hi Richard, Thanks, I have read this article, but it only covers data access, whereas I specifically need the reports / printing functionality. The basic idea is that my access database is linked to an MS SQL database, and takes its data from there. Data access simply goes through MS SQL client. Regards, Johan

        My advice is free, and you may get what you paid for.

        Richard DeemingR 1 Reply Last reply
        0
        • J Johan Hakkesteegt

          Hi Richard, Thanks, I have read this article, but it only covers data access, whereas I specifically need the reports / printing functionality. The basic idea is that my access database is linked to an MS SQL database, and takes its data from there. Data access simply goes through MS SQL client. Regards, Johan

          My advice is free, and you may get what you paid for.

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          Johan Hakkesteegt wrote:

          I specifically need the reports / printing functionality.

          So what's wrong with the second example, "Print or Preview an Access Report"?


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          J 2 Replies Last reply
          0
          • Richard DeemingR Richard Deeming

            Johan Hakkesteegt wrote:

            I specifically need the reports / printing functionality.

            So what's wrong with the second example, "Print or Preview an Access Report"?


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            J Offline
            J Offline
            Johan Hakkesteegt
            wrote on last edited by
            #5

            Hi, Sorry, I mixed up the articles, because it mentions "...vs ADO...", and there is another article about using ADO to connect to an Access database. Anyway, my original code was written according to this article, and indeed worked fine. The problem is, that the code in this article no longer works once you install Office 2016 (at least the version that comes with Office365, if there is a difference), as apparently it does not include the Access Object Library. Regards, Johan

            My advice is free, and you may get what you paid for.

            1 Reply Last reply
            0
            • Richard DeemingR Richard Deeming

              Johan Hakkesteegt wrote:

              I specifically need the reports / printing functionality.

              So what's wrong with the second example, "Print or Preview an Access Report"?


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              J Offline
              J Offline
              Johan Hakkesteegt
              wrote on last edited by
              #6

              Hi Richard, It all turned out to be an installation issue with Office. After an online repair of my Office 2016 installation, the references were back, and my code ran just fine again. Thanks for your help though. Regards, Johan

              My advice is free, and you may get what you paid for.

              M 1 Reply Last reply
              0
              • J Johan Hakkesteegt

                Hi Richard, It all turned out to be an installation issue with Office. After an online repair of my Office 2016 installation, the references were back, and my code ran just fine again. Thanks for your help though. Regards, Johan

                My advice is free, and you may get what you paid for.

                M Offline
                M Offline
                Mycroft Holmes
                wrote on last edited by
                #7

                Johan Hakkesteegt wrote:

                It all turned out to be an installation issue with Office.

                and this is why most of us do not use office. Office and access are great tool but should be used for individual productivity not a developed application. MS has a track record of breaking office.

                Never underestimate the power of human stupidity RAH

                J 1 Reply Last reply
                0
                • M Mycroft Holmes

                  Johan Hakkesteegt wrote:

                  It all turned out to be an installation issue with Office.

                  and this is why most of us do not use office. Office and access are great tool but should be used for individual productivity not a developed application. MS has a track record of breaking office.

                  Never underestimate the power of human stupidity RAH

                  J Offline
                  J Offline
                  Johan Hakkesteegt
                  wrote on last edited by
                  #8

                  No argument here. I just use Access because it happens to be in Office anyway, and I have neither budget to purchase any better tools, nor the time to build my own.

                  My advice is free, and you may get what you paid for.

                  1 Reply Last reply
                  0
                  • J Johan Hakkesteegt

                    Hi, I have a couple of windows applications that use MS Access to print reports. They were built on MS Access 2007, and worked fine until I was forced to upgrade to Office365 and thus MS Access 2016. Unfortunately (apparently) Office365's version of Office 2016 does not allow you to have other Office versions installed, so I had to remove my Access 2007 version. The simplified version of my code that worked fine until now:

                    Dim oAccess As Access.Application
                    Dim x As Long
                    AccessExecutablePath = New FileInfo("C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE").FullName
                    x = Shell(AccessExecutablePath & " " & Chr(34) & DatabasePath & Chr(34) & " /runtime", AppWinStyle.MinimizedNoFocus)
                    oAccess = New Access.Application
                    oAccess = GetObject(DatabasePath)
                    oAccess.PrintReport("Some_Report_Saved_In_MSACCESS")

                    Apparently when you install Office 2016, it no longer has the necessary interop driver for Access, and the code no longer works. However, all microsoft's (I suppose outdated) documentation still says to use the code above. Here is my question: Has anyone else faced this issue, and more importantly can anyone suggest a solution, or another method to interact with the Access client? Regards, Johan

                    My advice is free, and you may get what you paid for.

                    A Offline
                    A Offline
                    Ash_savvy
                    wrote on last edited by
                    #9

                    Hai Johan, Me too faced the same problem recently, with excel 2013 and I fixed that by installing Office 2013 PIA (Primary Interop Assemblies). So here I strongly suggest you to install office 2016 PIA, which you can directly download from Microsoft official site. To know more about Microsoft Office PIA please refer: Office Primary Interop Assemblies[^]

                    Thanks and regards Ashwin 😃

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups