I'm getting an Error when executed the code. The error is 91 91 Object variable or With block variable not set. The error is trigger when the .Execute(MySQL) is executed.
Any suggestions? Don't know how to overcome this problem.
===========================================================
Dim acc As New Access.Application
Dim accAutoSec As MsoAutomationSecurity
Dim MySQL As String
On Error GoTo Errorhandler
'Capture current security setting
accAutoSec = acc.AutomationSecurity
'Reset the security to low temporarily to avoid the security warning
acc.AutomationSecurity = msoAutomationSecurityLow
acc.Application.Visible = False
acc.OpenCurrentDatabase strDbName, False, "mypassword"
MySQL = "INSERT INTO jsfAccountManagerDetail ( WBS, jsfRequirement, jsfAccountUmanager ) SELECT amReqXreftlb.WBS, amReqXreftlb.Number, amReqXreftlb.Account_ManagerID FROM amReqXreftlb"
With acc.CurrentDb
.Execute (MySQL) '<= The trigger to the problem.
.TableDefs.Refresh
End With
Set acc = Nothing
acc.Application.Quit
Exit_Sub:
Exit Function
Errorhandler:
If Err.Number <> 0 Then
MsgBox Err.Description, vbOKOnly, "Error"
Resume Exit_Sub
End If
End Function
Any suggestions? Don't know how to overcome this problem.
===========================================================
Dim acc As New Access.Application
Dim accAutoSec As MsoAutomationSecurity
Dim MySQL As String
On Error GoTo Errorhandler
'Capture current security setting
accAutoSec = acc.AutomationSecurity
'Reset the security to low temporarily to avoid the security warning
acc.AutomationSecurity = msoAutomationSecurityLow
acc.Application.Visible = False
acc.OpenCurrentDatabase strDbName, False, "mypassword"
MySQL = "INSERT INTO jsfAccountManagerDetail ( WBS, jsfRequirement, jsfAccountUmanager ) SELECT amReqXreftlb.WBS, amReqXreftlb.Number, amReqXreftlb.Account_ManagerID FROM amReqXreftlb"
With acc.CurrentDb
.Execute (MySQL) '<= The trigger to the problem.
.TableDefs.Refresh
End With
Set acc = Nothing
acc.Application.Quit
Exit_Sub:
Exit Function
Errorhandler:
If Err.Number <> 0 Then
MsgBox Err.Description, vbOKOnly, "Error"
Resume Exit_Sub
End If
End Function