0

THERE ARE TWO PARTS TO THIS QUESTION:

Part 1: Right now I have a form that will upload, insert, and delete from the table. I would like to have the last textbox link to a hyperlink.

Using this code works for hyperlinks (see below and see this: Access - Hyperlinks Aren't Linking), but now I need to change the text to say something like "Open attachment" instead of the file location. For buttons, I know this is done by using ".Caption" but what is the code to change the text for a textbox and to keep the hyperlink I just inserted?

Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
    With fd
    .AllowMultiSelect = False
    .Title = " Please select file"
        If .Show = True Then
            Selectfile = .SelectedItems(1)
            Me.txtHyperlink = "#" & Selectfile & "#"
        Else
            Exit Function
        End If
        Set fd = Nothing
 End With

Part 2: Whenever I insert the file path, the file also opens in another window. I want this to stop and to just link to the file and change the text box to say "Attachment", but also keep the link.

Community
  • 1
  • 1
Twizzle
  • 3
  • 2

1 Answers1

1

Part 1: Review http://www.allenbrowne.com/casu-09.html
A hyperlink entry contains three parts separated by pound signs (#). The template is: display text # file name # any reference within the file

Me.txtHyperlink = "Open Attachment#" & Selectfile & "#"  

Textbox IsHyperlink property must be set to Yes.

Part 2: don't really understand the issue.
What kind of files are you opening? What kind of window opens? Might need to use FollowHyperlink - review http://allenbrowne.com/func-GoHyperlink.html
I have encountered situation where FollowHyperlink would not work and so used Shell method:

Dim wsShell As Object  
Set wsShell = CreateObject("WScript.Shell")  
wsShell.Run Chr(34) & Me.tbxLink & Chr(34)
Harun24hr
  • 30,391
  • 4
  • 21
  • 36
June7
  • 19,874
  • 8
  • 24
  • 34
  • There we go!! I wasn't sure of the formatting with the display text going inside of the quotes! – Twizzle Mar 16 '17 at 19:40