none
Simple Run-time Message Box RRS feed

  • Question

  • I have an Access database that has, among other things, URL addresses that get followed when a product is selected and a button is clicked.

    The database is downloaded to their local because it has other features they can carry around and utilize without being online.

    However, if they wish to use the hyperlinks, they must be logged on and behind our firewall.

    If they aren't they get an error, but not always the same error name or number or description.

    I'd like a simple Msgbox, that says "Log on and get behind the firewall" when ANY error is thrown when that button is clicked.

    Does anyone have an idea as to how I can put this code in?  I've tried several aproaches, but it gets too complicated.  I just want something simple... On Error MsgBox.

    Thank you in advance for any help you can give me.


    Gee

    Tuesday, June 7, 2016 2:35 PM

Answers

  • Hi,

    Unless it's just the way the forum software formatted your post, it should look more like this:

    Private Sub SelectBtn_Click() On Error GoTo ErrorHandler Application.FollowHyperlink Me.URLtxt
    Exit Sub
    ErrorHandler: MsgBox "Please log in to get behind Firewall.",vbOKOnly,"Firewall Required" DoCmd.Close acForm, Me.Name End Sub

    Hope it helps...

    • Edited by .theDBguy Tuesday, June 7, 2016 4:12 PM
    • Marked as answer by GretaF Tuesday, June 7, 2016 4:18 PM
    Tuesday, June 7, 2016 4:11 PM

All replies

  • Hi Gee. Did you add an error handler already? Can you post the code behind the button? Thanks.
    Tuesday, June 7, 2016 2:55 PM
  • No I haven't so there's no code to post...can you help me with that?

    Just universal error handler with no specifics except an error occured?


    Gee

    Tuesday, June 7, 2016 3:00 PM
  • Okay, if I understand it, you're using Hyperlink fields in your table pointing to files behind the firewall. If so, then you can try using the form's Error event to let them know to log in behind the firewall. For example:

    Private Sub Form_Error(DataErr As Integer, Response As Integer)
    
    MsgBox "Please log in behind the firewall. Thank you.", vbInformation,"Error"
    
    End Sub
    

    Hope it helps...

    Tuesday, June 7, 2016 3:19 PM
  • Unfortunately that did not work.  I get the same error.


    Gee

    Tuesday, June 7, 2016 3:27 PM
  • Hi Gee. Sorry, I forgot one more thing:
    Private Sub Form_Error(DataErr As Integer, Response As Integer)
    
    MsgBox "Please log in behind the firewall. Thank you.", vbInformation,"Error"
    
    Response = acDataErrContinue
    
    End Sub

    Hope it helps...

    Tuesday, June 7, 2016 3:38 PM
  • I got it:

    Private Sub SelectBtn_Click()
    On Error GoTo ErrorHandler
    Application.FollowHyperlink Me.URLtxt
    ErrorHandler:
    MsgBox "Please log in to get behind Firewall.",vbOKOnly,"Firewall Required"
    End Sub

    N Now I need the form to close when "OK" is clicked...any ideas?


    Gee

    Tuesday, June 7, 2016 3:47 PM
  • I got it:

    Private Sub SelectBtn_Click()
    On Error GoTo ErrorHandler
    Application.FollowHyperlink Me.URLtxt
    ErrorHandler:
    MsgBox "Please log in to get behind Firewall.",vbOKOnly,"Firewall Required"
    End Sub

    N Now I need the form to close when "OK" is clicked...any ideas?


    Gee


    Just add DoCmd.Close acForm, Me.Name at the end.
    Tuesday, June 7, 2016 3:52 PM
  • Private Sub SelectBtn_Click()
    On Error GoTo ErrorHandler
    Application.FollowHyperlink Me.URLtxt
    ErrorHandler:MsgBox "Please log in to get behind Firewall.", vbOKOnly, "Firewall Required, DoCmd.Close acForm, Me.CompForm
    End Sub

    Highlights acForm and says Expected end of statement.


    Gee

    Tuesday, June 7, 2016 4:09 PM
  • Hi,

    Unless it's just the way the forum software formatted your post, it should look more like this:

    Private Sub SelectBtn_Click() On Error GoTo ErrorHandler Application.FollowHyperlink Me.URLtxt
    Exit Sub
    ErrorHandler: MsgBox "Please log in to get behind Firewall.",vbOKOnly,"Firewall Required" DoCmd.Close acForm, Me.Name End Sub

    Hope it helps...

    • Edited by .theDBguy Tuesday, June 7, 2016 4:12 PM
    • Marked as answer by GretaF Tuesday, June 7, 2016 4:18 PM
    Tuesday, June 7, 2016 4:11 PM
  • Perfect!

    I had the DoCmd.Close... portion as part of the MsgBox dialog line.

    Thank you the DB guy for your help!


    Gee

    Tuesday, June 7, 2016 4:18 PM
  • Hi Gee. You're welcome. Glad to hear you got it to work. Good luck with your project.
    Tuesday, June 7, 2016 4:21 PM