mrcw
07-17-2017, 08:26 AM
I'm running an access macro through excel and it works great the first time I do it then the second time I try to run it it always opens as read only. If I run it once then try to go to access and open the database manually it also opens as read only. After failing to fix the problem for awhile I added a function to check if the file was already open. When I try to run it a second time I get the "File already open" error.
Sub accessMacro()
Dim appAccess As Access.Application
Set appAccess = New Access.Application
Dim ObjAc As Access.Application
If IsFileOpen("Z:\Contracts\EXP\GX EXP BACKEND.accdb") Then
MsgBox ("File already open")
Else
With appAccess
.OpenCurrentDatabase "Z:\Contracts\EXP\GX EXP BACKEND.accdb"
.visible = True
.DoCmd.RunMacro "UPDATE GX EXP_SP"
.CloseCurrentDatabase
.Quit
End With
End If
End Sub
Any ideas on how to fix this are greatly appreciated.
Sub accessMacro()
Dim appAccess As Access.Application
Set appAccess = New Access.Application
Dim ObjAc As Access.Application
If IsFileOpen("Z:\Contracts\EXP\GX EXP BACKEND.accdb") Then
MsgBox ("File already open")
Else
With appAccess
.OpenCurrentDatabase "Z:\Contracts\EXP\GX EXP BACKEND.accdb"
.visible = True
.DoCmd.RunMacro "UPDATE GX EXP_SP"
.CloseCurrentDatabase
.Quit
End With
End If
End Sub
Any ideas on how to fix this are greatly appreciated.