错误处理程序中发生错误 [英] Error occurring in error handler

查看:71
本文介绍了错误处理程序中发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个全局错误处理程序,直到今天已经完美地运行了
。让我先提供相关代码


******************************* ******************* **************


错误GoTo Err_Ctrl


''此代码产生错误

如果Nz(Me.SubformCont.Form!txtUsage,"")="''那么

消息有问题

GoTo Exit_Sub

结束如果


Exit_Sub

DoCmd.Echo True

DoCmd.SetWarnings = True

Err_Ctrl:

errMsgStr ="

ctrlfnctnm =" ProcedureName"

Call Formname_err(Err.Number,Err.Description,Err.Source,ctrlfnctnm,

errMsgStr )

简历Exit_Sub


*************************** *********************** ********************

今天我不得不手工输入代码,所以除非有人要求,否则我不会包含

Formname_err程序。


T.他错误发生在以下行:

如果Nz(Me.SubformCont.Form!txtUsage,")=''''那么


我只能通过单步执行代码来确定导致代码转到

错误处理程序的原始错误。错误是:


你输入了没有值的表达式


错误是指子表单文本框txtUsage。这是一个正确的错误

就是这样。


但是:


一旦代码进入错误处理程序,

生成另一个错误,代码如下:


调用Formname_err(Err.Number,Err.Description,Err.Source, ctrlfnctnm,

errMsgStr)


错误是运行时错误'6''溢出


这导致错误处理程序失败并且未处理错误处理程序错误显示。


现在,我很确定错误处理程序代码没有编码错误。

我提出错误检查它运作正常。在子行格式文本框txtUsage导致

错误的行之前添加了以下

行。


Err。提高13


由于这个引发的错误,错误处理程序的工作原理与它应该是
完全相同,并显示已生成错误13并给出描述。


因此,我猜必须有一些关于生成错误的内容,因为导致此问题的子窗体文本框的



只是要添加,我不使用Link Child / Master属性。一切都是

未绑定。


-

通过AccessMonster.com发布的消息
http://www.accessmonster.com/Uwe/For。 ..ccess / 200602/1

I have a global error handler that up until today has
been working flawlessly. Let me first provide the relevant code

************************************************** **************

On Error GoTo Err_Ctrl

''This code is generating the error
If Nz(Me.SubformCont.Form!txtUsage,"") = "'' Then
Msg "There''s a problem"
GoTo Exit_Sub
End If

Exit_Sub
DoCmd.Echo True
DoCmd.SetWarnings = True

Err_Ctrl:
errMsgStr = ""
ctrlfnctnm = "ProcedureName"
Call Formname_err(Err.Number, Err.Description, Err.Source, ctrlfnctnm,
errMsgStr)
Resume Exit_Sub

************************************************** ********************

I''m having to type the code in by hand today, so I won''t include the
Formname_err procedure unless someone requests it.

The error is occuring on the following line:
If Nz(Me.SubformCont.Form!txtUsage,"") = "'' Then

I can only determine this original error that causes the code to go to the
Error Handler by stepping through the code. The error is:

"You entered and expression that has no value"

The error refers to the subform text box, txtUsage. This is a correct error
as this is the case.

HOWEVER:

Once the code enters the error handler, there is another error generated at
the following line of code:

Call Formname_err(Err.Number, Err.Description, Err.Source, ctrlfnctnm,
errMsgStr)

That error is "Run-time error ''6'' Overflow

This causes the error handler to fail and an "unhandled" error is displayed.

Now, I''m fairly certain that the error handler code is free of coding errors.
I raised an error to check that it was functioning correctly. The following
line was added before the line where the subform text box, txtUsage, causes
an error.

Err.Raise 13

With this raised error, the error handler works exactly as it is supposed to
and shows that error 13 has been generated and gives a description.

So, I guess there must be something about the error being generated because
of the subform textbox that is causing this problem.

Just to add, I do not use the Link Child/Master properties. Everything is
unbound.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200602/1

推荐答案

"运行时错误''6''"溢出是一个错误,它被一个处理器

异常所困,然后传递回你的错误处理程序。它根本不需要从你的代码中获得
:它可能是Access,Windows中或您的

代码中的错误。在Access中,它通常来自错误数据,或者因为Access已经评估参数或者因为数据库损坏而导致错误。请编译

(Google获取指示)和Compact你的数据库。如果错误仍然存​​在,

将代码发布到Formname_err(david)" robert d通过AccessMonster.com"

< u6836 @ uwe>在消息新闻中写道:5ba7892970a13 @ uwe ...
"Run-time error ''6''" Overflow is an error which is trapped bya processor
exception, then passed back up to your error handler.It doesn''t have to come
from your code at all: it could bea bug in Access, or in Windows, or in your
code. In Access,it often comes from bad data, or because Access has madean
error evaluating a parameter, or because of database corruption.Decompile
(Google for instructions) and Compact your database.If the error persists,
post the code to Formname_err(david)"robert d via AccessMonster.com"
<u6836@uwe> wrote in message news:5ba7892970a13@uwe...
我有一个全局错误处理程序,直到今天才能完美运行。让我先提供相关代码

*********************************** *************** **************
-
通过AccessMonster.com发布的消息
< a rel =nofollowhref =http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/200602/1target =_ blank> http://www.accessmonster.com /Uwe/For...ccess/200602/1
I have a global error handler that up until today has
been working flawlessly. Let me first provide the relevant code

************************************************** ************** --
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200602/1



从你发布的内容来看,你的Exit_Sub并没有退出sub。你需要一个退出

Sub在那里。


-

兰迪哈里斯

tech在promail dot com

我'我很确定我知道我记得的一切。

" robert d via AccessMonster.com" < u6836 @乌韦>写在消息中

新闻:5ba7892970a13 @ uwe ...
From what you posted, your Exit_Sub doesn''t exit the sub. You need an "Exit
Sub" in there.

--
Randy Harris
tech at promail dot com
I''m pretty sure I know everything that I can remember.
"robert d via AccessMonster.com" <u6836@uwe> wrote in message
news:5ba7892970a13@uwe...
我有一个全局错误处理程序,直到今天已经完美地工作。让我先提供相关代码

*********************************** *************** **************

错误GoTo Err_Ctrl

' '此代码产生错误
如果Nz(Me.SubformCont.Form!txtUsage,")=''''那么
Msg"那就有问题了
GoTo Exit_Sub
结束如果

Exit_Sub
DoCmd.Echo True
DoCmd.SetWarnings = True

Err_Ctrl:
errMsgStr = "
ctrlfnctnm =" ProcedureName"
调用Formname_err(Err.Number,Err.Description,Err.Source,ctrlfnctnm,
errMsgStr)
Resume Exit_Sub

********************************************* ***** ********************

我今天要手工输入代码,所以我赢了除非有人提出要求,否则不包括
Formname_err程序。

错误发生在以下行:
如果Nz(Me.SubformCont.Form!txtUsage," ")=" 那么

我只能确定导致代码通过代码加强去
错误处理这种原始的错误。错误是:

您输入并且没有值的表达式

错误是指子表单文本框txtUsage。这是一个正确的
错误,因为这种情况。

但是:

一旦代码进入错误处理程序,就会产生另一个错误
在以下代码行:

调用Formname_err(Err.Number,Err.Description,Err.Source,ctrlfnctnm,
errMsgStr)

该错误是 ;运行时错误''6''溢出

这导致错误处理程序失败并且未处理错误错误是
显示。
现在,我很确定错误处理程序代码没有编码
错误。我提出错误以检查它是否正常运行。
以下行是在子窗体文本框txtUsage,
导致错误的行之前添加的。

Err.Raise 13

引发错误,错误处理程序的工作原理与
相同,并显示已生成错误13并给出描述。

所以,我猜必须有一些关于错误的内容生成
,因为导致此问题的子窗体文本框。

只是要添加,我不使用Link Child / Master属性。一切都没有了。

-
通过AccessMonster.com发布消息
http://www.accessmonster.com/Uwe/For...ccess/200602/1
I have a global error handler that up until today has
been working flawlessly. Let me first provide the relevant code

************************************************** **************

On Error GoTo Err_Ctrl

''This code is generating the error
If Nz(Me.SubformCont.Form!txtUsage,"") = "'' Then
Msg "There''s a problem"
GoTo Exit_Sub
End If

Exit_Sub
DoCmd.Echo True
DoCmd.SetWarnings = True

Err_Ctrl:
errMsgStr = ""
ctrlfnctnm = "ProcedureName"
Call Formname_err(Err.Number, Err.Description, Err.Source, ctrlfnctnm,
errMsgStr)
Resume Exit_Sub

************************************************** ********************

I''m having to type the code in by hand today, so I won''t include the
Formname_err procedure unless someone requests it.

The error is occuring on the following line:
If Nz(Me.SubformCont.Form!txtUsage,"") = "'' Then

I can only determine this original error that causes the code to go to the
Error Handler by stepping through the code. The error is:

"You entered and expression that has no value"

The error refers to the subform text box, txtUsage. This is a correct error as this is the case.

HOWEVER:

Once the code enters the error handler, there is another error generated at the following line of code:

Call Formname_err(Err.Number, Err.Description, Err.Source, ctrlfnctnm,
errMsgStr)

That error is "Run-time error ''6'' Overflow

This causes the error handler to fail and an "unhandled" error is displayed.
Now, I''m fairly certain that the error handler code is free of coding errors. I raised an error to check that it was functioning correctly. The following line was added before the line where the subform text box, txtUsage, causes an error.

Err.Raise 13

With this raised error, the error handler works exactly as it is supposed to and shows that error 13 has been generated and gives a description.

So, I guess there must be something about the error being generated because of the subform textbox that is causing this problem.

Just to add, I do not use the Link Child/Master properties. Everything is
unbound.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200602/1






我可以看到两件可能导致你头疼的事情
I can see two things that might be causing you a headdache
1.如果是Nz (Me.SubformCont.Form!txtUsage,"")="''然后


如果那是你的代码的复制粘贴然后你得到了你的最终报价

标记错误 - 你有一个双引号后跟一个单引号,

而不是两个双或两个单身......但这段代码甚至不应该是

编译 - 它会给你一个错误信息,说然后。是

预期。

2. Exit_sub:
1. If Nz(Me.SubformCont.Form!txtUsage,"") = "'' Then
if thats a copy paste of your code then you''ve got your final quote
marks wrong - you have a double quote followed by a single quote,
rather than two double or two singles... but this code shouldnt even
compile - it would give you an erro message saying that a "Then" is
expected.
2. Exit_sub:




中没有任何内容实际退出sub。应该有一个退出

Sub声明。当代码到达终点时,它将通过exit_sub:部分正确运行

并进入err_crtl: - 即使有

没有错误。

但是当代码试图在没有错误时使用错误对象时,你会得到的错误是一个对象未​​设置错误,而不是

溢出错误。


....简而言之 - 代码中的其他地方还有另一个问题。

1.修复上述2个错误

2.注释掉你的on_error说明

3.运行代码并在出错时单击调试以确切查看代码

的确切位置。



has nothing in it that actually exits the sub. there should be an "Exit
Sub" statement in it. When the code gets to the end it will run right
through the exit_sub: section and go into err_crtl: - even if there is
no error.
But when the code tries to use an err object when there is none, the
resulting error you will get is an object not set error, not an
overflow error.

....in short - there''s another problem somewhere else in the code.
1. Fix the above 2 errors
2. comment out your "on_error" instructions
3. run code and click debug on error to see exactly where the code
breaks.


这篇关于错误处理程序中发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆