Linking to file

B

BruceM

I have been working on this for a while, searching Help and newsgroups, but
I have taken it as far as I can on my own. I have a database to track
Recommendations made within the company. Sometimes the response to the
Recommendation involves pictures, pdf files, and so forth. I have a command
button to place a link to the file (the picture, etc.) into a text box
(txtLink) that is bound to a Hyperlink field. I can then click on the text
box and go to that file, but I want a command button to accomplish the same
thing.
On the first point, I can use a command button to open the Insert Hyperlink
dialog box, and from there can navigate through Network Places to the file
location. I have to use UNC file locations because of drive letter
inconsistencies from one computer to the next. To do this, in the Insert
Hyperlink dialog box I click File (under Browse For), then I click My
Network Places. Is there any way to have the Insert Hyperlink dialog box
open at that point, or to otherwise accomplish that objective? I suspect
not, but no harm in asking.
On the second point, the hyperlink is placed in the text box txtLink. If I
click on it I can go to the file. However, I wanted a command button to
perform this operation. I tried something like this in the command botton's
Click event:

Dim strLink as String
strLink = Me.txtLink
FollowHyperlink strLink

But I was informed that the file could not be found. The error message
showed the file name bracketed by number signs. So I tried:

Dim hypLink as Hyperlink
hypLink = Me.txtEvidenceLink
FollowHyperlink hypLink

But this led to Error 91 (Object variable not set, or whatever).

So I went back to the first choice, but used Mid to get rid of the number
signs in the text string:

Dim strLink as String
strLink = Me.txtLink
strMid = Mid(strLink, 2, Len(strLink) - 1)
FollowHyperlink strMid

This works, but it strikes me as a rather odd way to approach it. Am I
missing something here? Also, out of curiosity, Dim ... as String seems to
be unnecessary. Is a text string assumed if it is not specified otherwise?

In any case, there could be any number of files associated with a particular
Recommendation, so the table in which the link appears will be a child table
to the main Recommendation table. The main form will have a subform based
on the child table.

Am I on track here, or is there a better way of linking to files in network
locations?
 
Top