当前位置: 动力学知识库 > 问答 > 编程问答 >

vba - Determine if Attachment field is empty

问题描述:

How can you determine if in Attachment field in Access does not contain an attachment using VBA? I tried

If IsNull(rstMassBalance.Fields("FileName"))

and

If rstMassBalance.Fields("FileName") = Null

but neither of these work. It either does nothing or gives me run-time error 3021 that says "No current record"

网友答案:

I don't use the Attachments field, but the attachments are retrieved into a Recordset2 from the Value property of the attachments-field.

Dim rsChild As DAO.Recordset2

Set rsChild = rstMassBalance.Fields("FileName").Value

I'm not sure if this will return Nothing or an empty recordset if there are no attachments. So either:

If rsChild Is Nothing Then
'or 
If rsChild.RecordCount  <= 0 Then   'probably this one

There is a lot of information to be garnered from this Access Blog.

Work with Attachments in DAO suggests that you could check:

If rsChild.EOF Then
分享给朋友:
您可能感兴趣的文章:
随机阅读: