标题: excel调用access里面的数据报错?请看看什么原因?谢谢 [打印本页] 作者: yanwei82123300 时间: 2019-12-19 23:58 标题: excel调用access里面的数据报错?请看看什么原因?谢谢 各位老师看看我使用excel调用access数据,但是提示我有字段有误,
run time error '2147217900(80040e14)':
undefined function 'nz' in excpression
Sub CreateQuery()
'引用Microsoft ActiveX Data Objects 2.x Library
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim SQL As String
Dim i As Integer
cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\test.accdb"
SQL = "SELECT * FROM qrySO_Linked_WO_Tag_Detail" '是由这个查询数据
rst.Open SQL, cnn, adOpenKeyset, adLockOptimistic
Cells.ClearContents
For i = 0 To rst.Fields.Count - 1
Cells(1, i + 1) = rst.Fields(i).Name
Next
Range("A2").CopyFromRecordset rst
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub