Vba 访问错误:未找到方法或数据成员

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17049508/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 15:50:20  来源:igfitidea点击:

Vba Access error: Method or data member not found

vbamethodsaccess-vbams-access-2010

提问by KuroNeko

I have been trying to open a contracts form from contracts_all page. I want to open all the records on the contracts_all form but only show the specific one clicked on. To show this one particular record, the button uses ID found in the contracts_all form. I have managed to go this far with the help of various people in different forums but now I am getting an error which says "Compiler error; Method or data member not found".. Please help! Thanks in advance.

我一直在尝试从 contract_all 页面打开合同表格。我想打开contracts_all 表单上的所有记录,但只显示单击的特定记录。为了显示这一特定记录,该按钮使用了在 contract_all 表单中找到的 ID。在不同论坛中不同人的帮助下,我已经成功做到了这一点,但现在我收到一个错误消息,显示“编译器错误;未找到方法或数据成员”.. 请帮忙!提前致谢。

Dim Rs As Recordset
Dim Test As Integer
Dim varBookmark As Variant
DoCmd.OpenForm "Contracts"

Set Rs = Forms!Contracts.RecordsetClone
    Rs.FindFirst ("[ID] = '" & Me![ID] & "'")
varBookmark = Rs.Bookmark
 Forms!Contracts.Form.Bookmark = varBookmark

If Rs.NoMatch Then
  MsgBox "That does not exist in this database."
Else
End If

回答by dennythecoder

It looks like you may not have the appropriate references set. Make sure you have Microsoft DAO checked. Note that these methods will not work in ADO. :-)

看起来您可能没有设置适当的参考。确保您已检查 Microsoft DAO。请注意,这些方法在 ADO 中不起作用。:-)

Click Tools, then References, then Microsoft DAO 3.6 (or highest version available). Not having the correct library referenced is easy to miss if you copied and pasted code into your project.

单击工具,然后单击引用,然后单击 Microsoft DAO 3.6(或可用的最高版本)。如果您将代码复制并粘贴到项目中,则很容易错过引用正确的库。

Cheers, LC

干杯,LC

回答by Johnny Bones

Try replacing

尝试更换

Rs.FindFirst ("[ID] = '" & Me![ID] & "'")

with

Rs.FindFirst ("[ID] = '" & Forms!contracts_all![ID] & "'")

That may be slightly off, but I'm guessing it's because your active form has changed from contracts_all to Contracts, so you can no longer use the Me! reference.

这可能有点偏差,但我猜这是因为您的活动形式已从 contract_all 更改为 Contracts,因此您不能再使用 Me!参考。

回答by Juddles

Another possibility is that the fields you are attempting to clear are set to Date or Number format, for example, which was the case in my database. I did learn a lot from looking through numerous threads on this topic though!

另一种可能性是您尝试清除的字段设置为日期或数字格式,例如,在我的数据库中就是这种情况。不过,我确实从有关此主题的众多主题中学到了很多东西!