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

trap hyperlink error

P: n/a
Hi Everbody

I am trying to trap the error that SHOULD occur when there is no
internet connection.

Private Sub CmdPayHere_Click()
On Error GoTo Err_CmdPayHere_Click
Application.FollowHyperlink "http://www.microsoft.com"
Err_CmdPayHere_Click:
MsgBox "Page Not Available, Check that You ARE online",
vbInformation, "No Internet Connection"
End Sub

However, the above code displays the error message whether there is a
connection or not

Also, when there is NO CONNECTION, there is no error displayed at all.
All that happens is the browser does not display.

Thanks in advance for any help.

Bob

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
> I am trying to trap the error that SHOULD occur
when there is no internet connection. However, the above code displays the error message
whether there is a connection or not
See my inline VBA comments below:

Private Sub CmdPayHere_Click()

On Error GoTo Err_CmdPayHere_Click

Application.FollowHyperlink "http://www.microsoft.com"

' In normal operation, you must exit the sub before your
' error handler. Otherwise execution passes straight through
' and runs the code in your Error handler block.
Exit_CmdPayHere_Click:
Exit Sub

Err_CmdPayHere_Click:
MsgBox "Page Not Available, Check that You ARE online",
vbInformation, "No Internet Connection"

' I also like to do this. This way, my procedure has exactly
' one exit point and exactly one entry point. But some folks
' hate Goto's more than me:
Goto Exit_CmdPayHere_Click

End Sub

--
Peace & happy computing,

Mike Labosh, MCSD

"When you kill a man, you're a murderer.
Kill many, and you're a conqueror.
Kill them all and you're a god." -- Dave Mustane
"bobdydd" <re**************@yahoo.co.uk> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... Hi Everbody

I am trying to trap the error that SHOULD occur when there is no
internet connection.

Private Sub CmdPayHere_Click()
On Error GoTo Err_CmdPayHere_Click
Application.FollowHyperlink "http://www.microsoft.com"
Err_CmdPayHere_Click:
MsgBox "Page Not Available, Check that You ARE online",
vbInformation, "No Internet Connection"
End Sub

However, the above code displays the error message whether there is a
connection or not

Also, when there is NO CONNECTION, there is no error displayed at all.
All that happens is the browser does not display.

Thanks in advance for any help.

Bob

Nov 13 '05 #2

P: n/a
THanks Mike. That did the trick.

Nov 13 '05 #3

P: n/a
"Mike Labosh" <ml*****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...

' In normal operation, you must exit the sub before your
' error handler. Otherwise execution passes straight through
' and runs the code in your Error handler block.
Exit_CmdPayHere_Click:
Exit Sub

Err_CmdPayHere_Click:
MsgBox "Page Not Available, Check that You ARE online",
vbInformation, "No Internet Connection"

' I also like to do this. This way, my procedure has exactly
' one exit point and exactly one entry point. But some folks
' hate Goto's more than me:
Goto Exit_CmdPayHere_Click


Mike: Try using Resume Exit_CmdPayHere_Click. It ensures that the
application realizes that the error has been handled.

Good advice, btw.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

Nov 13 '05 #4

P: n/a
> Mike: Try using Resume Exit_CmdPayHere_Click. It ensures that the
application realizes that the error has been handled.


[slapping forehead] OOPS! Yes, because Resume also clears the error
condition. Can you tell it's been a while since I used VBA?

--
Peace & happy computing,

Mike Labosh, MCSD

"When you kill a man, you're a murderer.
Kill many, and you're a conqueror.
Kill them all and you're a god." -- Dave Mustane
Nov 13 '05 #5

P: n/a
Thanks Doug
I will alter it to that.

Bob

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.