基本上,我用数据库中的数据填充表单。为此,我有一个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/