473,418 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

On Error Resume Next

I know On Error Resume Next is generally considered lazy. But can
someone tell me why the resume next in Exit_Handler does not seem to
work? It generates the typical unhandled runtime error message from
Access. If I comment out the 1st On Error Resume Next and the x = 1 /
0 on the next line there is no difference, i.e. ther same unhandled
error on the same line. I included these 2 lines of code to
demonstrate that On Error Resume Next does work in some cases. Anyone
know why its "not working" in Exit_Handler?
Private Sub Command44_Click()

Dim x%
On Error Resume Next
x = 1 / 0
On Error GoTo Error_Handler
x = 1 / 0

Exit_Handler:
On Error Resume Next
x = 1 / 0 'runtime error here is not ignored (i.e. not "skipped")
by the resume next
On Error GoTo 0
Exit Sub

Error_Handler:
GoTo Exit_Handler

End Sub

Mar 6 '06 #1
3 27381
The error handler can only handle one error at a time. So when you
triggered the first error, there is still an active error when you triggered
the error in Exit_handler. You must first "handle' the error in err_handler
by using the "resume" statement. If you change "goto exit_handler" with
"resume Next" you'll see it works.


<bo*********@yahoo.com> wrote in message
news:11**********************@j52g2000cwj.googlegr oups.com...
I know On Error Resume Next is generally considered lazy. But can
someone tell me why the resume next in Exit_Handler does not seem to
work? It generates the typical unhandled runtime error message from
Access. If I comment out the 1st On Error Resume Next and the x = 1 /
0 on the next line there is no difference, i.e. ther same unhandled
error on the same line. I included these 2 lines of code to
demonstrate that On Error Resume Next does work in some cases. Anyone
know why its "not working" in Exit_Handler?
Private Sub Command44_Click()

Dim x%
On Error Resume Next
x = 1 / 0
On Error GoTo Error_Handler
x = 1 / 0

Exit_Handler:
On Error Resume Next
x = 1 / 0 'runtime error here is not ignored (i.e. not "skipped")
by the resume next
On Error GoTo 0
Exit Sub

Error_Handler:
GoTo Exit_Handler

End Sub

Mar 6 '06 #2
Yeah thats it, thanks!

Mar 6 '06 #3

Err.Clear, On Error Goto, and On Error Resume
do not reset the 'Resume' flag, but they do
wipe out the error object:
Error_Handler:
On Error Resume Next
MsgBox Err.number & ": " & Err.Description
x = 1 / 0 'runtime error here is not ignored (i.e. not "skipped") by
the resume next

Even though they do not reset the 'Resume' flag, they need
to be used with caution if you write an error handling
routine.

(david)


"Matthew Wells" <MW****@FirstByte.net> wrote in message
news:5l***************@newsread3.news.atl.earthlin k.net...
The error handler can only handle one error at a time. So when you
triggered the first error, there is still an active error when you
triggered
the error in Exit_handler. You must first "handle' the error in
err_handler
by using the "resume" statement. If you change "goto exit_handler" with
"resume Next" you'll see it works.


<bo*********@yahoo.com> wrote in message
news:11**********************@j52g2000cwj.googlegr oups.com...
I know On Error Resume Next is generally considered lazy. But can
someone tell me why the resume next in Exit_Handler does not seem to
work? It generates the typical unhandled runtime error message from
Access. If I comment out the 1st On Error Resume Next and the x = 1 /
0 on the next line there is no difference, i.e. ther same unhandled
error on the same line. I included these 2 lines of code to
demonstrate that On Error Resume Next does work in some cases. Anyone
know why its "not working" in Exit_Handler?
Private Sub Command44_Click()

Dim x%
On Error Resume Next
x = 1 / 0
On Error GoTo Error_Handler
x = 1 / 0

Exit_Handler:
On Error Resume Next
x = 1 / 0 'runtime error here is not ignored (i.e. not "skipped")
by the resume next
On Error GoTo 0
Exit Sub

Error_Handler:
GoTo Exit_Handler

End Sub


Mar 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jitu>> | last post by:
Hi All, I've a query on On Error Resume Next. I've explained what I understand for each case, I'm not sure that this is true. Case: 1] Used in Function/Sub: will resume to the next statement...
7
by: jason | last post by:
Is there a way to avoid On Error Resume Next for: cnn.Open strCon SQL = "EXEC Customer @txtEmail='" & email_address & "'" set rs = cnn.execute(SQL) 'On error resume next rs("email_address")...
3
by: Laphan | last post by:
Hi Everybody I put the On Error Resume Next command as the very first line in my ASP pages, which may contain various inc files and sub-routines/functions, so that I can try and stop the dreaded...
2
by: tom blower | last post by:
Access 2k (10.6501.6714) SP3 For YEARS the code line "On Error Resume Next" has worked without any problems. It is an essential tool. A couple of days ago, I put in another hard drive, mentioned...
5
by: itsupport1 | last post by:
Hi, I am importing some records from one table to another table, and due to Constraints in the destination table, it Throws an Exception and Skip the Whole Rest of records. So I did implement...
4
by: Neo | last post by:
I found on error resume next doesn't work in for each... e.g. on error resume next for each x in y 'do stuff next if you have an error in for each loop, it falls in infinite loop... it...
11
by: Maxwell2006 | last post by:
Hi, I know that this is not a good practice, but I wonder do we have "on error resume next" in C#? Thanks,
4
esimond
by: esimond | last post by:
Hi All ! Just joined this big community, and a BIG Swiss Hello in there ! Having recently switched from VB to C#, I indeed still have to discover all the powerful sides of that great...
18
by: julietbrown | last post by:
Can you boost my understanding of Access? I don't like things I can 'cure' but don't understand why! I've converted the Save macro on my form to VBA. It looks like this ... as I'm sure you...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.