Code to Launch website using Access 2007

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amoller
    New Member
    • Apr 2020
    • 1

    Code to Launch website using Access 2007

    So real newbie at coding. Have a form with field Hyperlink
    Trying to get a button to launch said hyperlink but keep getting a runtime 8 error. Here's my code for the click button.

    Code:
    Private Sub Toggle40_Click()
        Dim strInput As String
        strInput = Screen.ActiveForm![Hyperlink]
        Application.FollowHyperlink strInput
    
    End Sub
    Last edited by twinnyfo; Apr 20 '20, 10:25 AM. Reason: added mandatory code tags.
  • cactusdata
    Recognized Expert New Member
    • Aug 2007
    • 223

    #2
    This will work - if your button not is a toggle button and will be renamed to something meaningful:

    Code:
    Private Sub OpenHyperlink_Click()
    
        Dim Address As String
        
        Address = Me![Hyperlink].Hyperlink.Address
        Application.FollowHyperlink Address
    
    End Sub

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      Hi AMoller.

      This is complicated due to the lack of information that would be needed to help properly. I would assume that the following means you have a Control on the current Form named Hyperlink and that this control is probably a TextBox :
      Originally posted by AMoller
      AMoller:
      Have a form with field Hyperlink
      That is probably the easy part.

      Originally posted by AMoller
      AMoller:
      Trying to get a button to launch said hyperlink but keep getting a runtime 8 error.
      While error numbers are never a problem, they don't tell us much without having to go and look them up to find the text of the error message. Feel free to post the number as well, but it's always a good idea to include the text. In this case I was unable to determine any message for error #8 so completely in the dark :-(

      Originally posted by AMoller
      AMoller:
      Here's my code for the click button.
      As far as the code goes there's nothing obviously wrong. However, the names raise questions.
      1. If it's a Command Button (CmdButton) control why is it named Toggle40? I suspect you've dragged a ToggleButton control onto your Form instead of a CmdButton. It's an easy mistake to make if you aren't very familiar with things.
      2. Access has a Hyperlink object. Be very careful with names of your own items (Forms / Controls / etc). They can lead people to misunderstand what it is you're trying to do. In this case I suspect the Control is actually a TextBox that happens to be called Hyperlink - as opposed to a Hyperlink control itself. I suspect that confused CactusData into giving that particular suggestion.
      3. An alternative to the code you have, after adjusting for using a (properly named) CmdButton instead of the existing Control, would be :
        Code:
        Private Sub cmdLink_Click()
            Call FollowHyperlink(Address:=Me.txtHyperlink.Text)
        End Sub

      Let us know how you get on with this.

      Comment

      • lewish95
        New Member
        • Mar 2020
        • 33

        #4
        In the top left of the Access window and then click on the Access Options button. When the Access Options window appears, click on the Current Database tab. Then in the Display Form drop-down, select the forum that you wish to open at startup.

        Comment

        Working...