So i have some code that runs on a form unload so that it gets triggered when the database is close
However i am recieving an error 91: Object Variable or With block variable not set on the linePrivate Sub Form_Unload(Cancel As Integer) On Error Resume Next CurrentProject.Connection.CommandTimeout = 10 CurrentProject.Connection.Close CurrentProject.OpenConnection "" On Error GoTo 0 Dim fso As FileSystemObject If fso.FileExists(CurrentProject.path & "\Tools\Connected.dat") Then fso.DeleteFile (CurrentProject.path & "\Tools\Connected.dat") End If On Error Resume Next CloseForms End Sub
I am unable to find an error in the code and am thinking it may be because the form is unloading?If fso.FileExists(CurrentProject.path & "\Tools\Connected.dat") Then
Any thoughts would be apriciated.