vba - Microsoft Access VBA打开错误

标签 vba ms-access compiler-errors

基本上,我用数据库中的数据填充表单。为此,我有一个onopen事件,其中仅包含以下代码:

Me.Requery

直到昨天,一切都运转良好,突然发生了错误。错误状态:

The expression OnOpen you entered as the event property produced the following error: Instruction invalid outside of a type-block.



在说明中表示的附加语:

  • The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
  • There may have been an error evaluating the function, event or macro.


当我去寻求帮助时,它说:

This error occurs when an event has failed to run because the location of the logic for the event cannot be evaluated. For example, if the OnOpen property of a form is set to =[Field], this error occurs because a macro or event name is expected to run when the event occurs.



但是,当我单击该消息时,一切都正确加载。

我在用:
-Microsoft Access 2013

问答:

您的代码是否编译成功?

是的,其余的都很好。它还可以将所有内容正确加载到表单中。但是,每次启动时,都会 pop 此信息字段。

编辑:我刚刚注意到我所有的单击事件现在都引发相同的错误。

您能显示整个代码吗?

实际上,我已注释掉所有其他内容以解决该错误。如果删除onopen事件,则信息框将消失。

最佳答案

如评论中所述,编译可以通过查找错误的访问修饰符之类的错误来解决问题。
编译顺利后,应删除Form_Load函数,并让IDE重新创建它。这解决了我的问题,因为显然没有观察到代码更改。

关于vba - Microsoft Access VBA打开错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45275064/

相关文章:

vba - 检查错误或 vbNullString 类型不匹配

excel - 在工作簿之间共享一个模块?

mysql - 与弹出部分匹配的 SQL 查询

java - JDBC ODBC 驱动程序连接

c++ - c++11 编译器中出现额外限定错误的问题

VBA Excel 使用表名检查特定表是否存在

vba - 通过双击突出显示 MS excel 2007 中的单元格

在 ms-access 表中插入多行的 SQL 代码

android - Android NDK : Compiling errors using libpcap for Android - functions “not declared in this scope”

c - 未定义对 'pow' 的引用,即使 -lm 是一个编译标志。 [C]