我的代码运行良好,但是当我重新打开数据库时,我收到以下错误;有谁知道我怎么解决这个问题?一旦我打开数据库,并运行代码几次,我就不会再出错了。
运行时错误'91'未设置对象变量
Sub ImportAllTables_New_Click()
Dim dt As Date
dt = Now() 'save current single timestamp for later use
DoCmd.SetWarnings False
On Error GoTo errHandler
Call LoadData("C:\Idea Attributes\tbl_IdeasITAssumptions.xlsm", "TempIdeasITAssumptions", "Qry_IdeasITAssumptions", "Qry_AppendIdeasITAssumptions")
Call LoadData("C:\Idea Attributes\tbl_IdeasDependencies.xlsm", "TempIdeasDependencies", "Qry_IdeasDependencies", "Qry_AppendIdeasDependencies")
Call LoadData("C:\Idea Attributes\tbl_IdeasImpactedPlan.xlsm", "TempIdeasImpactedPlan", "Qry_IdeasImpactedPlan", "Qry_AppendIdeasImpactedPlan")
Call LoadData("C:\Idea Attributes\tbl_IdeasImpactedSubsidiaries.xlsm", "TempIdeasImpactedSubsidiaries", "Qry_IdeasImpactedSubsidiaries", "Qry_AppendIdeasImpactedSubsidiaries")
Call LoadData("C:\Idea Attributes\tbl_IdeasLOB.xlsm", "TempIdeasLOB", "Qry_IdeasLOB", "Qry_AppendIdeasLOB")
Call LoadData("C:\Idea Attributes\tbl_IdeasPhaseGate.xlsm", "TempIdeasPhaseGate", "Qry_IdeasPhaseGate", "Qry_AppendIdeasPhaseGate")
Call LoadData("C:\Idea Attributes\tbl_IdeasDataExtractMain.xlsm", "TempIdeasDataExtractMain", "Qry_IdeasDataExtractMain", "Qry_AppendIdeasDataExtractMain")
'update all [Load_date] that are greater than the timestamp captured before you started import
DoCmd.RunSQL "UPDATE [tbl_IdeasITAssumptions] set [Load_Date] = #" & dt & "# where [Load_Date] > #" & dt & "#"
DoCmd.RunSQL "UPDATE [tbl_IdeasDependencies] set [Load_Date] = #" & dt & "# where [Load_Date] > #" & dt & "#"
DoCmd.RunSQL "UPDATE [tbl_IdeasImpactedPlan] set [Load_Date] = #" & dt & "# where [Load_Date] > #" & dt & "#"
DoCmd.RunSQL "UPDATE [tbl_IdeasImpactedSubsidiaries] set [Load_Date] = #" & dt & "# where [Load_Date] > #" & dt & "#"
DoCmd.RunSQL "UPDATE [tbl_IdeasLOB] set [Load_Date] = #" & dt & "# where [Load_Date] > #" & dt & "#"
DoCmd.RunSQL "UPDATE [tbl_IdeasPhaseGate] set [Load_Date] = #" & dt & "# where [Load_Date] > #" & dt & "#"
DoCmd.RunSQL "UPDATE [tbl_IdeasDataExtractMain] set [Load_Date] = #" & dt & "# where [Load_Date] > #" & dt & "#"
DoCmd.SetWarnings True
MsgBox ("All Tables has been Imported")
errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"
End Sub