Nov 14 2021 03:08 AM
I need to manage the code on an external access file that acts as a control of the lock situation verified on the main file which must then be closed and reopened
from Db A I close and reopen the Db B.
Ecco il codice
Private Sub chiude_apre_Click()
' ---> Chiude il file Ship.accdb e lo riavvia
If Dir(Application.CurrentProject.Path & "\Chiudi e riavvia.vbs") = "" Then
Open Application.CurrentProject.Path & "\Chiudi e riavvia.vbs" For Output As #1
Print #1, "Dim shell"
Print #1, "Set shell = wscript.CreateObject(""Wscript.Shell"")"
Print #1, "shell.run ""taskkill /fi """"WINDOWTITLE eq Access - Ship*"""""""
Print #1, "shell.run """"""" & "C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE"""" """"" & Application.CurrentProject.Path & _
"\Ship.accdb"""""""
Print #1, "set shell = nothing"
Close #1
End If
Call shell("WScript.exe """ & Application.CurrentProject.Path & "\Chiudi e riavvia.vbs", vbHide)
End Sub
It opens the DB B file for me but doesn't close it
the line that should close the file is:
Print #1, "shell.run ""taskkill /fi """"WINDOWTITLE eq Access - Ship*"""""""
Someone can tell me where I'm wrong
Thanks for your answers
Dec 02 2021 12:49 PM