+ Reply to Thread
Results 1 to 2 of 2

Thread: Opening an Access Table using Excel VBA

  1. #1
    Registered User
    Join Date
    01-26-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    10

    Opening an Access Table using Excel VBA

    Morning All

    I am currently trying to develop a piece of code which will connect to an MS Access database and then kick off a Query on the table

    I am using the following code:

    
    Public strDB As String
    Public A As Object
    Public Function runaccessmacro()
    Application.ScreenUpdating = False
    Set A = CreateObject("Access.Application")
    strDB = "S:\MI_Portal\TMNT\TMNT (TESTING).mdb"
    A.OpenCurrentDatabase strDB
    A.Visible = False
    A.DoCmd.RunMacro "mcrUpdateNumberStatus"
    A.Quit
    Set A = Nothing
    Application.ScreenUpdating = True
    End Function
    
    Sub run_access_macro()
    Call runaccessmacro
    End Sub
    But this does not work and am presented with error message '7866', which suggests the table can not be found or is locked by another user

    I have also tried to following code, but get the same error message:

    
    Global oApp As Object
    
    Sub OpenAccess()
    
        Dim LPath As String
        Dim LCategoryID As Long
    
        'Path to Access database
        LPath = "\\RLBYCCMPFS06\swap\MI_Portal\TMNT\TMNT (TESTING).mdb"
        
        'Open Access and make visible
        Set oApp = CreateObject("Access.Application.11")
        oApp.Visible = True
    
        'Open Access database as defined by LPath variable
        oApp.OpenCurrentDatabase LPath, False
    
        'Open form called Categories filtering by CategoryID
        oApp.Visible = False
        oApp.DoCmd.RunMacro "mcrUpdateNumberStatus"
        oApp.Quit
    
    End Sub
    Any suggestions??
    Last edited by SakebR; 09-09-2011 at 05:45 AM.

  2. #2
    Extremely Helpful member
    Join Date
    12-23-2006
    Location
    Belgium
    MS-Off Ver
    XL2003
    Posts
    6,127

    Re: Opening an Access Table using Excel VBA

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Quoting entire posts clutters the forum and makes threads hard to read !

    If you are pleased with a member's answer then use the Star icon to rate it

    Click here to see forum rules

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0