使用Access VBA,我尝试将目录中的文件加载到[table name]
[field name]
Data Type
字段Attachment
中的表Invalid field data type
。
问题是我收到错误Dim SQL As String
SQL = " SELECT * FROM [table name] WHERE ID = '10'"
Dim VESRecordSet As Recordset
Set VESRecordSet = CurrentDb.OpenRecordset(SQL)
VESRecordSet![field name].LoadFromFile "D:\Documents\file.vsd"
。
代码如下。
.arrow-down {
width: 100%;
margin: 0 auto;
text-align: center;
}
.arrow-down::after {
content: "";
width: 40px;
height: 40px;
position: absolute;
margin-top: 49%;
margin-left: 48%;
top: 0;
right: 0;
bottom: 0;
left: 0;
border-right: 4px solid rgb(255, 0, 0);
border-bottom: 4px solid rgb(0, 255, 0);
-webkit-transform: rotate(45deg);
animation: 3s arrow infinite ease;
}
答案 0 :(得分:0)
您犯了多个错误:
DAO.RecordSet2
对象.LoadFromFile
.Edit
和.Update
最终代码:
Dim SQL As String
SQL = " SELECT * FROM [table name] WHERE ID = '10'"
Dim VESRecordSet As DAO.Recordset2
Dim rsAttachments As DAO.Recordset2
Set VESRecordSet = CurrentDb.OpenRecordset(SQL)
VESRecordSet.Edit
Set rsAttachments = VESRecordSet![field name].Value
rsAttachments.AddNew
rsAttachments.Fields("FileData").LoadFromFile "D:\Documents\file.vsd"
rsAttachments.Update
rsAttachments.Close
VESRecordSet.Update
VESRecordSet.Close