Access 2007 中的 DAO 中出现奇怪的字段分配问题
这是我的上一个问题的后续问题。
当我解决了参考文献的问题后,我遇到了另一个非常奇怪的问题。 基本上,我在表单上的按钮后面有以下内容:
Dim attachmentField As DAO.Field2
attachmentField = Recordset("Att")
我现在已经链接了引用,在第二行放置了一个断点,并在 Recordset("Att") 上添加了一个监视。 当执行在断点处停止时,我可以从手表中看到 Recordset("Att") 返回一个 Variant/Object/Field2 类型的值,并且该字段包含几乎我所期望的内容。
但是,当我跨过第二行(允许其执行)时,会弹出以下错误:“未设置对象变量或 With 块变量”
,当然,附件字段在完成后不会被分配任何内容。 我缺少什么?
This is a follow-up on my previous question.
Once I got the problem with the reference sorted out, I ran into another pretty strange issue. Basically, I have the following behind a button on a form:
Dim attachmentField As DAO.Field2
attachmentField = Recordset("Att")
I have now linked the reference, placed a break point on the second line and added a watch on Recordset("Att"). When execution stops on the break point, I can see from the watch that Recordset("Att") returns a value of type Variant/Object/Field2, and the field contains pretty much what I expect it to.
But when I step over the second line (allow it to execute) the following error pops up: "Object variable or With block variable not set"
And of course attachmentField is assigned Nothing when it's done. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在分配行的开头使用“Set”。
设置 AttachmentField = Recordset("Att")
You will need to use "Set" at the start of the assignment line.
Set attachmentField = Recordset("Att")