Dynamic hyperlinks

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sueb
    Contributor
    • Apr 2010
    • 379

    Dynamic hyperlinks

    I'd like to put a button my my form that, when clicked, opens a Microsoft Explorer window to a location specified by a static string (a drive and partial path) and the value of a text field in my database (the final step in the path).

    I have no idea how to do this. Is it even possible?

    Thanks in advance!
  • sueb
    Contributor
    • Apr 2010
    • 379

    #2
    Failing that, can I fill a field in the record with the desired hyperlink, so that the user could then click on that?

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by sueb
      I'd like to put a button my my form that, when clicked, opens a Microsoft Explorer window to a location specified by a static string (a drive and partial path) and the value of a text field in my database (the final step in the path).

      I have no idea how to do this. Is it even possible?

      Thanks in advance!
      It's my bedtime, but here is the general idea. Any questions, feel free to ask.
      Code:
      Dim retVal As Variant
      Dim strPartialPath As String
      Const conPAth As String = "C:\Windows\"
      
      If Not IsNull(Me![txtPath]) Then
        If Left$(Me![txtPath], 1) = "\" Then
          strPartialPath = Mid$(Me![txtPath], 2)
        Else
          strPartialPath = Me![txtPath]
        End If
      Else
        Exit Sub
      End If
      
      If Dir$(conPAth & strPartialPath, vbDirectory) <> "" Then
        retVal = Shell("Explorer.exe " & conPAth & strPartialPath, vbMaximizedFocus)
      Else
        MsgBox "The Path [" & conPAth & strPartialPath & "] is not valid", vbExclamation, "Invalid Path"
      End If

      Comment

      • sueb
        Contributor
        • Apr 2010
        • 379

        #4
        Originally posted by ADezii
        It's my bedtime, but here is the general idea. Any questions, feel free to ask.
        Code:
        Dim retVal As Variant
        Dim strPartialPath As String
        Const conPAth As String = "C:\Windows\"
        
        If Not IsNull(Me![txtPath]) Then
          If Left$(Me![txtPath], 1) = "\" Then
            strPartialPath = Mid$(Me![txtPath], 2)
          Else
            strPartialPath = Me![txtPath]
          End If
        Else
          Exit Sub
        End If
        
        If Dir$(conPAth & strPartialPath, vbDirectory) <> "" Then
          retVal = Shell("Explorer.exe " & conPAth & strPartialPath, vbMaximizedFocus)
        Else
          MsgBox "The Path [" & conPAth & strPartialPath & "] is not valid", vbExclamation, "Invalid Path"
        End If
        Thanks so much--I'm still at home this morning, but I'll try this out at work today!

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Be advised, sueb, that this is not a Hyperlink.

          Comment

          • sueb
            Contributor
            • Apr 2010
            • 379

            #6
            Originally posted by ADezii
            It's my bedtime, but here is the general idea. Any questions, feel free to ask.
            Code:
            Dim retVal As Variant
            Dim strPartialPath As String
            Const conPAth As String = "C:\Windows\"
            
            If Not IsNull(Me![txtPath]) Then
              If Left$(Me![txtPath], 1) = "\" Then
                strPartialPath = Mid$(Me![txtPath], 2)
              Else
                strPartialPath = Me![txtPath]
              End If
            Else
              Exit Sub
            End If
            
            If Dir$(conPAth & strPartialPath, vbDirectory) <> "" Then
              retVal = Shell("Explorer.exe " & conPAth & strPartialPath, vbMaximizedFocus)
            Else
              MsgBox "The Path [" & conPAth & strPartialPath & "] is not valid", vbExclamation, "Invalid Path"
            End If
            Wow, that was great! Now (and I guess I should have included this in my original question), can I create the "invalid" directory?

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32645

              #7
              For a continuation of this new question see (Create Directory).

              Comment

              Working...