Results 1 to 12 of 12

How to view access file if already opened using VBA?

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    How to view access file if already opened using VBA?

    Hi,
    I searched and there are a ton of links on how to open access files using VBA, but I couln't find (or maybe i wasn;t looking in the right place) code on how to bring the access file in foreground if it's already opened. Below is the code I use with no luck.
        'open the access tool if not already open
        If Not IsFileOpen(strPath) Then         'IsFileOpen checks and returns true if file is already open depending on strPath (file path) 
            
            'close any open access instances
            Call CloseAllAccess
        
            Set oApp = CreateObject("Access.Application")
            oApp.AutomationSecurity = 1
            oApp.OpenCurrentDatabase strPath    
            oApp.Visible = True
            oApp.DoCmd.OpenTable "tbl_Material"
            oApp.DoCmd.OpenForm "frmCPanel"
            Set oApp = Nothing
        Else
            Set oApp = CreateObject("Access.Application")
            oApp.AutomationSecurity = 1
            oApp.OpenCurrentDatabase strPath                    'i am pretty sure this line shouldn;t be here, but i can;t figure what to put instead
            oApp.DoCmd.OpenTable "tbl_Material"
            oApp.DoCmd.OpenForm "frmCPanel"
        End If
    Thanks
    Last edited by adds007; 11-29-2010 at 10:01 AM.

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1