locked
Error running Interop.Access in VB.NET RRS feed

  • Question

  • I get an error "type access.application is not defined".
    I have
    Imports Microsoft.Office.Interop.Access
    and I have
    Microsoft Access 11.0 Object Library  
    installed as a Com Reference.
    Other References I have installed are:
    Microsoft ActiveX Data Objects 2.7 Library
    Microsoft Office 11.0 Object Library
    Microsfot Visual Basic for Applications Extensibility 5.3

    I'm running VS2008

    The code is:

                    Imports Microsoft.Office.Interop
    ......
                    Dim
    thereport As New Access.Application
            thereport.OpenCurrentDatabase(("C:\Alcis\ALCISltemp.mdb"))
            thereport.DoCmd.RunMacro("trptBank") 'works
            thereport.Application.Visible = True
            ' Close the Access database
            thereport.DoCmd.RunCommand(Microsoft.Office.Interop.Access.AcCommand.acCmdWindowHide)
            thereport.DoCmd.OpenReport(ReportName, Microsoft.Office.Interop.Access.AcFormView.acPreview) 'acViewPreview
            thereport.DoCmd.Maximize()

    Wednesday, April 30, 2008 5:10 AM

Answers

  • You'll have to update your office installation from the CD to include the .NET, use modify installation->advanced-> and for each application you want to use (e.g. Microsoft Access or Microsoft Excel), enable ".NET Programmability Support". 
    I believe you have to first install .NET 2.0 or 3.5 depending if you're using Office 2003 or 2007 respectively.

    See also:

    Good luck!

    I ran into some problems with the CD also: (not sure if you'll have those problems, but just in case)
    1. I had to make sure the Office Source Engine service is enabled and running. 
    2. I had to use Microsoft LIS tool to disable the use of local source:
    • Proposed as answer by izzy_zii Wednesday, February 18, 2009 6:53 PM
    • Marked as answer by Martin Xie - MSFT Thursday, February 19, 2009 3:27 AM
    Wednesday, February 18, 2009 6:49 PM
  •  HarleyALC wrote:
    I get an error "type access.application is not defined".
    I have
    Imports Microsoft.Office.Interop.Access
    and I have
    Microsoft Access 11.0 Object Library  
    installed as a Com Reference.
    I'm running VS2008

    The code is:
                    Imports Microsoft.Office.Interop

                    Dim
    thereport As New Access.Application

     

    Hi HarleyALC,

     

    I add Microsoft Access 11.0 Object Library and try the following code samples, they work fine.

     

    1.

    Code Snippet

    Imports Microsoft.Office.Interop

     

        Dim thereport As New Access.Application

     

     

    2.

    Code Snippet

    Imports Microsoft.Office.Interop.Access

     

       Dim thereport As New Application

     

     

    3. Using full namespace path

    Code Snippet
    Dim thereport As New Microsoft.Office.Interop.Access.Application

     

     

     

    Best regards,

    Martin

    Thursday, May 1, 2008 6:22 AM
  • The trick was to go in to Programs and Settings and change the MS Office advanced options to include the .net library.
    Monday, May 5, 2008 10:48 PM

All replies

  •  HarleyALC wrote:
    I get an error "type access.application is not defined".
    I have
    Imports Microsoft.Office.Interop.Access
    and I have
    Microsoft Access 11.0 Object Library  
    installed as a Com Reference.
    I'm running VS2008

    The code is:
                    Imports Microsoft.Office.Interop

                    Dim
    thereport As New Access.Application

     

    Hi HarleyALC,

     

    I add Microsoft Access 11.0 Object Library and try the following code samples, they work fine.

     

    1.

    Code Snippet

    Imports Microsoft.Office.Interop

     

        Dim thereport As New Access.Application

     

     

    2.

    Code Snippet

    Imports Microsoft.Office.Interop.Access

     

       Dim thereport As New Application

     

     

    3. Using full namespace path

    Code Snippet
    Dim thereport As New Microsoft.Office.Interop.Access.Application

     

     

     

    Best regards,

    Martin

    Thursday, May 1, 2008 6:22 AM
  • Thanks for the input Martin,

    I tried all of the suggestions and get the exact same error "type access.application is not defined".

    Any ideas what else it could be ?.
    Friday, May 2, 2008 3:25 AM
  • In references under Microsoft Access 11.0 Object Library I get the location <the system could not find the reference specified>
    Friday, May 2, 2008 3:30 AM
  •  HarleyALC wrote:

    I have
    Imports Microsoft.Office.Interop.Access
    and I have
    Microsoft Access 11.0 Object Library  
    installed as a Com Reference.
    ....

    In references under Microsoft Access 11.0 Object Library I get the location <the system could not find the reference specified>

     

    Please make sure the following steps have been done:

    1. MS Access 2003 has been installed.

    2. Add Microsoft Access 11.0 Object Library to your project:

       Project menu -> Add Reference -> COM tab -> Navigate to Microsoft Access 11.0 Object Library

    Friday, May 2, 2008 4:11 AM
  • The trick was to go in to Programs and Settings and change the MS Office advanced options to include the .net library.
    Monday, May 5, 2008 10:48 PM
  • Hi HarleyALC,

    Can you please eloborate on your trick to solve this problem.. I could not grasp what you mean by "go in to Programs and Settings and change the MS Office advanced options to include the .net library."

    Tuesday, September 2, 2008 12:11 PM
  • You'll have to update your office installation from the CD to include the .NET, use modify installation->advanced-> and for each application you want to use (e.g. Microsoft Access or Microsoft Excel), enable ".NET Programmability Support". 
    I believe you have to first install .NET 2.0 or 3.5 depending if you're using Office 2003 or 2007 respectively.

    See also:

    Good luck!

    I ran into some problems with the CD also: (not sure if you'll have those problems, but just in case)
    1. I had to make sure the Office Source Engine service is enabled and running. 
    2. I had to use Microsoft LIS tool to disable the use of local source:
    • Proposed as answer by izzy_zii Wednesday, February 18, 2009 6:53 PM
    • Marked as answer by Martin Xie - MSFT Thursday, February 19, 2009 3:27 AM
    Wednesday, February 18, 2009 6:49 PM