Hyperlink Text, Creating With VBA

B

Bob

I currently use A2003 w/sp3 on a lan. All databases are designed FE/
BE.

A piece of the code of a module I've written inserts the hyperlink to
a file stored on our lan:

strHypName = "#" & strFinalizedPath & "\" &
strFilename & "#"

' Append information to table
sql = "INSERT INTO d_right_fax_files
( file_loc) " _
& "VALUES ( '" & strHypName & "');"
db.Execute sql

and it works fine.
Example of a path: I:\_DepartmentXXX\RightFax\Finalized
\ThedocNameHere.rtf
What I'd like to display: ThedocNameHere.rtf


If one right clicks a hyperlink in datasheet view, the link can be
edited. The view is nicer if the text displaying does not include the
entire path to the file it's linked to. Is there a way to accomplish
changing the text property of the hyperlink? Wher/how is the text
property saved differently from that of the hyperlink path?

Thank you for taking a look.

Bob
 
B

Bob

I currently use A2003 w/sp3 on a lan.  All databases are designed FE/
BE.

A piece of the code of a module I've written inserts the hyperlink to
a file stored on our lan:

                        strHypName = "#" & strFinalizedPath & "\" &
strFilename & "#"

                        ' Append information to table
                        sql = "INSERT INTO d_right_fax_files
( file_loc) " _
                        & "VALUES ( '" & strHypName & "');"
                        db.Execute sql

and it works fine.
Example of a path:  I:\_DepartmentXXX\RightFax\Finalized
\ThedocNameHere.rtf
What I'd like to display:  ThedocNameHere.rtf

If one right clicks a hyperlink in datasheet view, the link can be
edited.  The view is nicer if the text displaying does not include the
entire path to the file it's linked to.  Is there a way to accomplish
changing the text property of the hyperlink?  Wher/how is the text
property saved differently from that of the hyperlink path?

Thank you for taking a look.

Bob

I've answered my own question.

It turns out that a hyperlink data type may have up to four segments,
which are delimited by the # sign. The first segment is the text
that's displayed. My query was appending the entire path and only the
first segment, so the entire HL displays. To display only the file
name my query needs to look like this:
INSERT INTO d_right_fax_files ( file_loc )
SELECT '#J02752054_Maher_Masih_0818.xls#\\bsc\hcs\medops\_DepartmentXXX
\RightFax\Finalized\J02752054_Maher_Masih_0818.xls#' AS Expr1;

Note, that the first segment includes the text I want to display and
not the path. For a detailed reading on the segments, see Programming
Microsoft Access, Version 2002, by Rick Dobson, pg 876 (just happens
to be the hull number of my first Navy duty station...)

Regards,
Bob
 
D

Daniel Pineault

You can do this by specifying the text to diaplay prior to the #...# part of
your code. For Instance, try something like:

strHypName = strFilename & "#" & strFinalizedPath & "\" & strFilename & "#"
' Append information to table
sql = "INSERT INTO d_right_fax_files ( file_loc) " _
& "VALUES ( '" & strHypName & "');"
db.Execute sql

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 

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