Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Why would a error handler not catch an error?

Posted on 2006-05-11
4
Medium Priority
?
216 Views
Last Modified: 2010-05-01
For some reason, the error handler below does NOT catch the error. This bit of code sometimes gets a error 91. I have this same type of error handler (minus the elseif err.number = 424) elsewhere in my code and it works fine. The error label is not mispelled.  I've verified the code does not even reach the ErrCoke4: label.



On Error GoTo ErrCoke4
Do Until InStr(1, IE.Document.body.innertext, "Update Records") <> 0
    txtImageCode.Text = "Looping until 'Update Records' <> 0"
    DoEvents
    If KoKoMo& < Timer Then
        Exit Do 'If the loop runs for 30 seconds, then exit the loop.
    End If
Loop





ErrCoke4:
If Err.Number = 91 Then
    txtImageCode.Text = "Err 91 - Verifying 'Update Records' page failed"
    Sleep 1
    GoTo Coke4
ElseIf Err.Number = 424 Then
    txtImageCode.Text = "Err 424 - Verifying 'Update Records' page failed"
    Sleep 1
    GoTo Coke4
Else
    Err.Raise (Err.Number & ", " & Err.Description)
End If
0
Comment
Question by:JohnDoeSr
4 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16664987
You have this in there:

    GoTo Coke4

Where is the Coke4 label?

Can you post the entire sub/function that contains this?

There must be more there...for example, how are you preventing the code from dropping down into the error handler code when the loop is dropped out of?

etc...
0
 
LVL 6

Expert Comment

by:junglerover77
ID: 16665272
What Idle_Mind said is absolute right.

If your Coke4 label is in somewhere prior to the code, errors will not be caught again when it was raised the second time.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 1000 total points
ID: 16665867
Also, you should

Resume Coke4

otherwise you are still logically in error handling mode.
0
 
LVL 1

Expert Comment

by:tushar_comp
ID: 16666000
hi,

 if this is function or sub then error handling shuld be like below

 Public Function Test()
 
  On Error GoTo ErrCoke4
  Do Until InStr(1, IE.Document.body.innertext, "Update Records") <> 0
    txtImageCode.Text = "Looping until 'Update Records' <> 0"
    DoEvents
    If KoKoMo& < Timer Then
        Exit Do 'If the loop runs for 30 seconds, then exit the loop.
    End If
  Loop
  Exit Function
 
  ErrCoke4:
            If Err.Number = 91 Then
            txtImageCode.Text = "Err 91 - Verifying 'Update Records' page failed"
            Sleep 1
            GoTo Coke4
            ElseIf Err.Number = 424 Then
            txtImageCode.Text = "Err 424 - Verifying 'Update Records' page failed"
            Sleep 1
            GoTo Coke4
            Else
            Err.Raise (Err.Number & ", " & Err.Description)
            End If

End Function

but i have one doubt
 that why r using GoTo  Coke4
 THIS means ur moving control somewhere after trapping error
 elaborate on this

 try to use err.discription what is the error in error handler that makes it more relevent
 
 if i m wromg correct me
 if all these is useful

 Let me know
 
 Tushar

 

 
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question