我已經搜索了這個答案,但我無法找到任何我可以理解的,因爲我是一個小白點,並尋找外行的解釋。在我的宏中導致自動化錯誤/未指定錯誤2147467259(80004005)是什麼?
當您點擊提交時,該宏將推送一些數據以進行訪問。
只要我可以告訴它可能與ActiveX數據對象引用有關,但說實話這是我的第一個這種類型的項目,我真的可以使用一些幫助。
這是我的代碼:
Sub ADOFromExcelToAccess()
' exports data from the active worksheet to a table in an Access database
' this procedure must be edited before use
Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long
' connect to the Access database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=M:\DataBase2.mdb;"
' open a recordset
Set rs = New ADODB.Recordset
rs.Open "ShiftSwapData", cn, adOpenKeyset, adLockOptimistic, adCmdTable
' all records in a table
r = 3 ' the start row in the worksheet
Do While Len(Range("A" & r).Formula) > 0
' repeat until first empty cell in column A
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("Date Submitted").Value = Trim(Cells(50, 1).Text)
.Fields("Agent Email").Value = Trim(Cells(50, 2).Text)
.Fields("Date Requested").Value = Trim(Cells(50, 3).Text)
.Fields("Payback Date 1").Value = Trim(Cells(50, 4).Text)
.Fields("Payback Date 2").Value = Trim(Cells(50, 5).Text)
.Fields("Shift Start").Value = Trim(Cells(50, 6).Text)
.Fields("Shift End").Value = Trim(Cells(50, 7).Text)
.Fields("RDO").Value = Trim(Cells(50, 8).Text)
.Fields("Call Type").Value = Trim(Cells(50, 9).Text)
' add more fields if necessary...
.Update ' stores the new record
End With
r = r + 1 ' next row
Loop
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
哪條線時,拋出的錯誤是突出? – Manhattan