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
Bookmarks