Results 1 to 8 of 8
  1. #1
    will71110 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Aug 2016
    Posts
    5

    Question Error Handling for FollowHyperlink

    Hello. I am trying to do some error handling with the FollowHyperlink. It's not working. Instead of my messages, I am still getting the standard VBA Window telling me there was an error. When there is no error, the code works fine. Here is my code I am currently using:



    Code:
    Private Sub List12_Click()
        On Error GoTo List12_Click_Handler
        Dim strRemover As String
        Dim strRealURL As String
        Dim opPos As Integer
        Dim clPos As Integer
        strRemover = Me.List12.Column(1)
        opPos = InStr(strRemover, "#")
        clPos = Len(strRemover)
        strRealURL = Mid(strRemover, opPos + 1, clPos - 1)
        FollowHyperlink strRealURL
        
    Exit_List12_Click:
        Exit Sub
        
    List12_Click_Handler:
        Select Case Err.Number
            Case 8:
                Resume Next
                MsgBox "You forgot to click your cert.  Please restart Access."
                Resume Exit_List12_Click
                
            Case Else:
                Resume Next
                MsgBox "URL is incorrect."
                Resume Exit_List12_Click
        End Select
    
    
    End Sub
    I want a message to popup when a URL is incorrect or if the data is not correct. I feel so defeated with now! Can anyone spot what I might be doing wrong?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    You do not need the : that makes it a label
    Code:
     Case 8:
                Resume Next
                MsgBox "You forgot to click your cert.  Please restart Access."
      
              Resume Exit_List12_Click
    When in doubt, use a Debug.Print Err.Number ' to show the value in the immediate window.

  3. #3
    will71110 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Aug 2016
    Posts
    5
    Thanks you. I took out the :. But I am still getting the VBA window. I tried the Debug.Print Err.Number but I'm not getting anything from that, just the VBA popup screen saying there is a run-time error '8'.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    If I'm not mistaken, the syntax would be Application.FollowHyperlink strRealURL
    You should post the message as well as the number. If I'm not mistaken, there is no "8" for Access 2007 or 2010, but there is a system error 8, which is "Not Enough Memory" which makes no sense for what you are doing.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  6. #6
    will71110 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Aug 2016
    Posts
    5
    Application followed by FollowHyperlink is implied because it is added as a Reference by default. Either way, adding the Application didn't fix the issue and I get the same results. The message I get is related to URLs which states (Run-Time error '8': "Cannot download the information you requested"). Can VBA override error handles like it's done in Java?

  7. #7
    will71110 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Aug 2016
    Posts
    5
    Ok, So I tried one I know is suppose to work. I divided 1/0 and I still get the Standard VBA popup. What gives? It's like "On Error" is disabled.

  8. #8
    will71110 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Aug 2016
    Posts
    5
    Ok...So I figured it out. It's nothing to do with the code. In the Code Editor Tools->Options->General and make sure Break on All Errors is not selected! I have put it on Break on Unhandled Errors and it is working great. I have no idea why that was changed. NotLikeThis :|

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 09-06-2015, 12:06 PM
  2. Replies: 2
    Last Post: 06-25-2015, 01:40 PM
  3. Error Handling Question - On Error Goto
    By redbull in forum Programming
    Replies: 7
    Last Post: 12-06-2012, 07:54 AM
  4. Replies: 3
    Last Post: 09-05-2012, 10:23 AM
  5. Reference is not valid FollowHyperlink error
    By kevint_cnc in forum Access
    Replies: 2
    Last Post: 09-04-2012, 02:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums