我在MS Access中制作报告时遇到了一个小问题。我在vba中编写了一个函数,并为RunCode(函数)创建了一个宏。因此,当我执行宏时,它会运行该函数并给我一个消息框。见图..
答案 0 :(得分:1)
为了将来参考,典型的“完整”错误处理结构例如是像这样:
Sub MySub()
On Error GoTo MySub_Err
' Stuff
MySub_Exit:
On Error Resume Next
' ... Stuff that always needs to run on exit can go here ...
' !! This is the important part that prevents the function
' !! from always running into the error handler:
Exit Sub
MySub_Err:
MsgBox Err.Description, vbExclamation, "Runtime Error " & Err.Number & " in MySub"
Resume MySub_Exit
End Sub
MZ-Tools可以自动创建此结构(但可自定义)。
答案 1 :(得分:1)
error_handler:
Error_handler: msgbox err.number& “ - ”&错误的描述
这给了我一个错误。
我没有做我的error_handler:正确(error_handler :)。我的功能完成后,它会遇到error_handler:msgbox err.number& “ - ”err.description并给我留言框 - 说“0 - ”,因为没有错误。我评论了它,一切似乎都运转正常。感谢@HansUp和其他所有人的帮助。