Store hyperlink, when filename may have # in the name?

L

lljo40

I tried posting this in another group, with no results, so I'm trying
again...

I need to store a hyperlink to the location of filenames in the
database. I have been successful in storing the formation (so far) by
assigning the field the required values separated by hash marks (#, or
pound signs or whatever you want to call them). Since Access requires
the # as the separator, I don't have an option to use another
character.

I have a text field on the form with a Browse button. The user selects
the file, using the browse button, and I store it in the text field as
follows: Me.txtContractLocation = strPath & "#" & strPath

This shows the full path as well as creating the hyperlink so the user
can click on it.

Now that it's working, I found a document (among the test documents the

user gave me) that has a name which has a hash mark in it called "File
Test #1.jpg". Needless to say, this totally screws up my current
method.

So, NOW what do I do???

I know, I know, tell the users NOT to use stupid names (but try telling

that to a bunch of engineers!).

Thoughts, comments, solutions???

Thanks,
Larry

BTW, Access 2003, Windows XP
 
T

TC

I don't use hyperlinks much, so this is just an eductated guess:

Try changing:
Me.txtContractLocation = strPath & "#" & strPath

to:
Me.txtContractLocation = """" & strPath & """#""" & strPath & """"

therby getting:
"c:\my folder"#"test#1.jpg"

instead of:
c:\my folder#test#1.jpg

As for getting them to use better filenames - my position would be,
that your code should handle any name that MS Windows allows them to
use.

HTH,
TC [MVP Access]
 
J

John Nurick

If you convert the path into a URL it seems to work:

Display Text#C:\Temp\File test #1.txt 'no good

Display Text#file:///C:/TEMP/File%20test%20%231.txt

It doesn't actually seem necessary to encode the spaces, just the hash.

I suspect it may be simpler in the long run to use a text field rather
than a hyperlink one, and just store the path. Then when you want to
open the file, use code to convert the name to URL format and pass the
result to Application.FollowHyperlink.
 
L

lljo40

Thanks for the comments. I was hoping this would be easy, but looks
like it's time for more code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top