By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,009 Members | 2,859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,009 IT Pros & Developers. It's quick & easy.

Error occurring in error handler

P: n/a
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
Feb 10 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"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...
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

Feb 10 '06 #2

P: n/a
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...
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


Feb 10 '06 #3

P: n/a
I can see two things that might be causing you a headdache
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:


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.

Feb 10 '06 #4

P: n/a
Guys, thanks for the responses and pointing out my errors.

I noted in my post that I had to type the code in by hand (rather than copy)
and obviously I made mistakes. The actual code does have Exit Sub in it and
the quotes are correct (I blew it when typing in the code).

I tried David's suggestion of decompiling the code. I followed the method
advocated by Allen Browne - backup, compact, decompile, compact, compile,
backup.

The problem did not go away. I stepped through the code to watch it enter
the error handler. Once the error handler is entered because of the error
generated by the subform textbox, txtUsage, and before it gets to the line
that gives me Error #6, here are the error stats:

Err.Number = -2147352567
Err.Description = "You entered an expression that has no value"
Err.Source =

If I can't solve this I'll probably have to add code that prevents the first
error (subform textbox) from occurring or handle it separately.

Would a reasonable solution be to add an "If" or "Case" statement on the
error, i.e.

If Err.Number = -2147352567 Then

Of course, I don't want to do this, but I may not have a choice.

Any other ideas are greatly appreciated.

Thanks.

BillCo wrote:
I can see two things that might be causing you a headdache
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:


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.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200602/1
Feb 10 '06 #5

P: n/a
> noted in my post that I had to type the code in by hand (rather than copy)
and obviously I made mistakes. The actual code does have Exit Sub in it and
the quotes are correct (I blew it when typing in the code).


....sorry for the crap advice then!
My best remain guess is that "Me.SubformCont.Form!txtUsage" doesnt
exist as addressed - which would explain why the code used to work but
doesnt anymore... something on the form has changed.

try inserting the line:
debug.print Me.SubformCont.Form!txtUsage
and see what hapens when the code hits it.

Feb 10 '06 #6

P: n/a
BillCo:

Maybe I should explain what I'm doing that causes the error. I'm creating a
complex chart that pulls data from a lot of tables does calcs, etc. One
subform contains values for parameters. The user can delete the rows shown
in this subform (continuous mode form) in order to tailor the output to
exactly what they want to see. Now what's shown in this first subform outputs
automatic (in code) calculational values to a second subform, which is the
one where I have the problem.

I was simply testing to see what happens if I delete all of the rows shown
on the first subform. This causes all rows shown in the second subform to
disappear (the second subform is also set to display as a continuous form).
And that is when the subform error appears. Which is fine, because the user
should not then press the "Calculate" button since there's nothing to
calculate. So, what I was trying to do was to check if there are values (see
first post) and then display a messagebox.

The more I think about it, I don't know why I even have the second subform.
It only ever displays one row, so there is no reason I couldn't replace it
with textboxes or labels on the main form. That will probably result in the
problem going away.

But I still don't understand why the error handler would fail. It should
just process the error like it has always processed all other errors.

When I insert your suggested line I get:

Run-time error '2427'

"You entered an expression that has no value"

It's interesting that the run-time error number is different now but the
message is the same as before. Is there any chance that the negative error
number (that I posted earlier) is what is causing the problem (ie. the fact
that it is negative and not positive)??

BillCo wrote:
noted in my post that I had to type the code in by hand (rather than copy)
and obviously I made mistakes. The actual code does have Exit Sub in it and
the quotes are correct (I blew it when typing in the code).


...sorry for the crap advice then!
My best remain guess is that "Me.SubformCont.Form!txtUsage" doesnt
exist as addressed - which would explain why the code used to work but
doesnt anymore... something on the form has changed.

try inserting the line:
debug.print Me.SubformCont.Form!txtUsage
and see what hapens when the code hits it.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200602/1
Feb 10 '06 #7

P: n/a
I think the error is primarily caused because when the last record is
removed from the subform then there are no instances of
"Me.SubformCont.Form!txtUsage" left to address, as it's continuous
forms... hence the "You entered an expression that has no value"
message when you tried my debug.print line of code. You are right
however - this all should be trapped by the error handler.

I'm at a loss to trace this one without stepping through your code
myself.
for instance whats going on in your Formname_err function? errMsgStr is
a zero length string - can Formname_er handle that? Where are errMsgStr
and ctrlfnctnm declaired?

Feb 10 '06 #8

P: n/a
Check my first post. You'll see that values are assigned to both errMsgStr
and ctrlfnctnm just prior to the line of code within the Error Handler that
is causing the Error Number 6 problem.

BillCo wrote:
I think the error is primarily caused because when the last record is
removed from the subform then there are no instances of
"Me.SubformCont.Form!txtUsage" left to address, as it's continuous
forms... hence the "You entered an expression that has no value"
message when you tried my debug.print line of code. You are right
however - this all should be trapped by the error handler.

I'm at a loss to trace this one without stepping through your code
myself.
for instance whats going on in your Formname_err function? errMsgStr is
a zero length string - can Formname_er handle that? Where are errMsgStr
and ctrlfnctnm declaired?


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200602/1
Feb 10 '06 #9

P: n/a
robert d via AccessMonster.com wrote:
Check my first post. You'll see that values are assigned to both errMsgStr
and ctrlfnctnm just prior to the line of code within the Error Handler that
is causing the Error Number 6 problem.

Hi Robert,

Have you tried stepping through you code, one line at a time? I prefer
to comment out the on error line when I do this as I don't jump to my
error proc when the error occurs (also, comment out the on error goto in
any calling procedures if applicable).

As an unsolicited aside, I don't like universal error handling, myself.
I find I have far more flexibility handling errors within each
routine. At very least, on creating a new procedure I toss in the
following at the end:

Exit_Proc:

Exit Sub

Err_Proc:

Select Case Err.Number

Case Else

MsgBox "Error " & Err.Number & " " & Err.Description,
vbCritical, "MyProcedureName", Err.HelpFile, Err.HelpContext

Resume Exit_Proc

End Select

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Feb 10 '06 #10

P: n/a
> The problem did not go away. I stepped through the code to watch it enter

Can you post the error handler declaration and code? Also, (at the risk
of being obvious), you will get that error if you try to pass that error
number to an Integer variable.

(david)
"robert d via AccessMonster.com" <u6836@uwe> wrote in message
news:5bac7a7ea26e7@uwe...
Guys, thanks for the responses and pointing out my errors.

I noted in my post that I had to type the code in by hand (rather than
copy)
and obviously I made mistakes. The actual code does have Exit Sub in it
and
the quotes are correct (I blew it when typing in the code).

I tried David's suggestion of decompiling the code. I followed the method
advocated by Allen Browne - backup, compact, decompile, compact, compile,
backup.

The problem did not go away. I stepped through the code to watch it enter
the error handler. Once the error handler is entered because of the error
generated by the subform textbox, txtUsage, and before it gets to the line
that gives me Error #6, here are the error stats:

Err.Number = -2147352567
Err.Description = "You entered an expression that has no value"
Err.Source =

If I can't solve this I'll probably have to add code that prevents the
first
error (subform textbox) from occurring or handle it separately.

Would a reasonable solution be to add an "If" or "Case" statement on the
error, i.e.

If Err.Number = -2147352567 Then

Of course, I don't want to do this, but I may not have a choice.

Any other ideas are greatly appreciated.

Thanks.

BillCo wrote:
I can see two things that might be causing you a headdache
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:


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.


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

Feb 13 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.