我有一个工作多年的Microsoft Access应用程序。但是今天下面的代码已经停止工作了。
Dim Recordset2 As DAO.Recordset2
Dim fieldAttachment As DAO.Field2
stringSQLText = "SELECT [" & stringTable & "].ID" & vbCrLf
stringSQLText = stringSQLText & " , [" & stringTable & "].[" & stringFieldName & "]" & vbCrLf
stringSQLText = stringSQLText & " FROM [" & stringTable & "]" & vbCrLf
stringSQLText = stringSQLText & " WHERE ((([" & stringTable & "].ID)=" & longID & "));"
Set Recordset2 = CurrentDatabase.OpenRecordset(stringSQLText, dbOpenSnapshot)
'Error occurs here
Set fieldAttachment = Recordset2(stringFieldName)
报告以下错误:
错误13类型不匹配
这可能是Office更新的结果吗?
还有人遇到过这个问题吗?
我的访问版本是Microsoft®Access®for Microsoft 365 MSO (Version 2206 Build 16.0.15330.20216) 64位
将代码改为Field3而不是Field2,现在可以工作了。