hyperlink with autonumber

H

helpplez

Consider a 3-column table. One 1st column is an autonumber
(primary key), the 2nd is a hyperlink to a text file, the
3rd is a description. As the user types a file description
the autonumber increments, and the hyperlink has a
format "path\[autonumber].txt", so links are created
automatically. How can I create the hyperlink?
 
A

Allen Browne

If the file exists, you could use the AfterUpdate event procedure of the
Description text box to set the Value of the hyperlink.

Something like this:

Private Sub Description_AfterUpdate()
Dim strFile As String
strFile = "C:\MyFolder\" & Me.[ID] & ".txt"
Me.[MyHyperlink] = strFile & "#" & strFile & "#"
End Sub

For an explanation of the # characters, see:
Introduction to Hyperlink fields
at:
http://allenbrowne.com/casu-09.html
 
H

helpplez

Thanks, it worked!
-----Original Message-----
If the file exists, you could use the AfterUpdate event procedure of the
Description text box to set the Value of the hyperlink.

Something like this:

Private Sub Description_AfterUpdate()
Dim strFile As String
strFile = "C:\MyFolder\" & Me.[ID] & ".txt"
Me.[MyHyperlink] = strFile & "#" & strFile & "#"
End Sub

For an explanation of the # characters, see:
Introduction to Hyperlink fields
at:
http://allenbrowne.com/casu-09.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

helpplez said:
Consider a 3-column table. One 1st column is an autonumber
(primary key), the 2nd is a hyperlink to a text file, the
3rd is a description. As the user types a file description
the autonumber increments, and the hyperlink has a
format "path\[autonumber].txt", so links are created
automatically. How can I create the hyperlink?


.
 
M

Mark Hyland

Hi,

You will need to write some code to do this. If the field names are:
id - autonumber
hlink - Hyperlink field
Des - description field

then on the after update event of the Des field, you could populate the
hyperlink using something like:

Me!hlink = "c:\" & Me!id & ".txt"

Obviously the path in this case is the C:\ drive, and the file extension is
.txt.

I hope this helps.

Regards

Mark


This information is provided "As is" and expresses no warranties or confers
no rights
 

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