Results 1 to 4 of 4

Thread: On Error VBA

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2010
    Posts
    12

    On Error VBA

    I have a little problem with the On Error Goto event. Does not seem like it catches the error all the time. It does sometimes. I am using VBA in Access. Here's some of the code that I am using with the on error statement. I get a Error number 91 when it tries to pull the information from the website if there is no data to pull. Any help is appreciated.

    Code:
    On Error GoTo Skip:
    
        AtmsQualsLength = WebBrowser1.Document.getelementbyid("tblQuals").rows.length - 1
    
    Skip:
    If Err.Number = 91 Then
        MsgBox stblBadgeNumber(i) & " is not found in ATMS!"
        Err.Clear
    End If
    Thanks,

    TheChazm

  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: On Error VBA

    Code:
    If WebBrowser1.Document.getelementbyid("tblQuals") Is Nothing Then
        AtmsQualsLength = WebBrowser1.Document.getelementbyid("tblQuals").rows.length - 1
    Else
        MsgBox stblBadgeNumber(i) & " is not found in ATMS!"
    End If
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2010
    Posts
    12

    Re: On Error VBA

    Thanks! I'll give that a shot and see if it works better. I know it does look better. I think I got wrapped around error handling to much.

    I'll post back soon and let you know.

    TheChazm

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: On Error VBA

    Also, your error routine will run every single solitary time you run your code because you are not existing your routine if there is no error
    Code:
    On Error GoTo Skip 'do not need a colon here
    
        AtmsQualsLength = WebBrowser1.Document.getelementbyid("tblQuals").rows.length - 1
    
    Exit Sub 'add this
    Skip:
    If Err.Number = 91 Then
        MsgBox stblBadgeNumber(i) & " is not found in ATMS!"
        Err.Clear
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width