PDA

View Full Version : Solved: automated hyperlinks



ecocentric
07-13-2007, 04:24 PM
I am looking for a way to have an active hyperlink to a document outside of the access database based on the current form record. I have a primary key index locked text box named [text0] on the form. I will store the document outside the database using the form record index number as the file name. I've built the expression
=IIf([check82]=-1,"C:\Documents and Settings\Administrator\Desktop\Benefits\" & [text0] & ".doc",Null)

When the checkbox is set on that form record the expression is loaded to a text field. I set the text field property to hyperlink but it doesn't work.
Any ideas?

OBP
07-14-2007, 06:43 AM
What mechanism are you using to activate the hyperlink?

ecocentric
07-14-2007, 07:49 AM
I had hoped to simply double click on the hyperlink to open the document. The idea is to store the docs outside the db and there will be only one doc associated with each record. The standard method of creating hyperlinks is annoying so I hoped that by naming each document after the index number, the form could utilize the index number to create the link. I don't know much VB beyond copy paste to a standard module and call the function from an event. That is why I've been trying to create this within access's standard tools. If there is a VB workaround I'd be willing to try it however.

mdmackillop
07-14-2007, 08:20 AM
Like Private Sub Check2_Click()
If Me.Check2 = True Then
Application.FollowHyperlink "C:\AAA\" & Text0 & ".xls"
End If
End Sub

ecocentric
07-14-2007, 08:41 AM
Thanks mdmackillop! It's not exactly what I had in mind but it does work and I can use it. I'll mark this solved.

ecocentric
07-14-2007, 02:31 PM
MD, Your solution works even better as a function
create new module:

function Button_Click()
Application.FollowHyperlink "C:\AAA\" & Form_name![Text0] & ".xls"
End function

Create a macro using "Run Code" with Button_Click()
Create a command button and call the macro from the on Click event

Thanks for this. It works great!

mdmackillop
07-14-2007, 03:20 PM
Hi Eco,
The proper use of a function is to return a value. While it can be used in this way, It's better to use a sub to keep things clear.

If you are going to call various documents, create a sub which uses a parameter passed to it, and call it using the button, change event or whatever.

Private Sub Command4_Click()
Call Link(Me.Text0)
End Sub

Sub Link(Data As String)
Application.FollowHyperlink "C:\AAA\" & Data & ".xls"
End Sub