Debug. Refer to link at bottom of my post for guidelines. Set breakpoint and step through code. Does the varFile variable get populated?
I tested this code and had to make one change.
GoHyperlink(Me.txtFile)
Debug. Refer to link at bottom of my post for guidelines. Set breakpoint and step through code. Does the varFile variable get populated?
I tested this code and had to make one change.
GoHyperlink(Me.txtFile)
Last edited by June7; 01-10-2014 at 01:50 AM.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I made the change to GoHyperlink(Me.txtFile) and when i choose a file using the dialog box the file opens straight away but the file path still does not appear in the text box. I tried using the debug thing but when i place the cursor at the start of the code and press F8, i just get a little chirp from the PC and nothing happens ? (not that i'd know what i'm looking at in any event)
Thanks
It has to be putting the value in textbox, otherwise the code could not open the file.
If you want to provide db for analysis, follow instructions at bottom of my post.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Thanks i'm attaching the database. Can i just get the link to appear in the textbox without the file opening ?
Certainly. Don't include the line that calls the GoHyperlink function.
You have the field set as a hyperlink type. Your code is grabbing the filename as normal text. If you want to save it as a hyperlink, it needs to be structured like a hyperlink as described in the other Allen Browne article.
The control is a listbox, not a textbox. Change it to a textbox.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Right i've changed the ListBox to a TextBox and removed the GoHyperlink line. Now when i select a file, the path appears in the textbox in blue but doesn't work as a link when i click it.
I looked at Allen Browne's other article but i don't really understand a lot of it....sorry
You want to save a hyperlink string and not use Allen Browne's GoHyperlink?
A hyperlink is composed of 3 parts, separated by a # character. Depending what the hyperlink is for, not all parts require text but the # separators are required regardless. Use string manipulation to construct a hyperlink string.
In your case, should be at least:
Me.txtFile = "#" & varFile & "#"
Allen's GoHyperlink function essentially does that, although not so obvious. Using Allen Browne's code will prevent the hyperlink warning popup.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
That's it working now. I have the field in the table set as hyperlink, i'm not using the GoHyperlink code, and i've amended my code to what you suggested above. It now allows you to select a file and the file path is displayed in the textbox. You can then click on the hyperlink to open the file (No warning messages).
Thanks for your patience with this June...i'm not very knowledgeable when it comes to VB. I appreciate you taking the time to get this working for me
Emma x
Interesting, you don't get the 'Hyperlinks are dangerous. Do you really want to open?' warning? Lucky you. Glad it's working.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.