MS Access 2003 - Hyperlink a field

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

BShick5088

Thread Starter
Joined
Jan 21, 2011
Messages
7
Good morning,

Is it possible to add code to the "On Dbl Click" of a data field to automatically open the Insert-Hyperlink menu?

I have a form that has a field pointing to a table with hyperlink set as a data type. What I want to do is easily be able to have a user enter a hyperlink to a project document on a network drive for future reference. I have it working now, but the user has to know to pick the drop menu INSERT then pick HYPERLINK to open the menu to browse to the document. What I would like to be able to do is when the user double clicks the field have the insert-hyperlink menu automatically open.

Is this possible?
Thanks,
Brian
 

karlhaywood

Account Closed
Joined
Jan 17, 2010
Messages
680
Hi, try this on the "On Dbl Click" event procedure.

Application.FileDialog(msoFileDialogOpen).Show
 

BShick5088

Thread Starter
Joined
Jan 21, 2011
Messages
7
Hi,
I tried and it gives a run-time error: Method 'FileDialog' of object '_Application' failed.

Anny suggestions?

Thanks,
Brian
 

OBP

Joined
Mar 8, 2005
Messages
19,895
Brian, welcome to the Forum.
I don't actually use the Hyperlink Type Field, I use a Text field and use the VBA FollowHyperlink code instead.
You may be able to the Docmd.DoMenuItem to invoke the Insert Hyperlink drop down, but I have never seen any code for it.
The other method, which karl was trying to use is to open a browser, but it is not quite the same as the Insert Hyperlink, but works extremely well with the text field method.
I can provide the code to do it that way if you want.
 

BShick5088

Thread Starter
Joined
Jan 21, 2011
Messages
7
Yes, please! Any help would be greatly appreciated.
I know these thongs are all possible I just have never had the opportunity to learn how to do them...

Thanks, again,
Brian
 

OBP

Joined
Mar 8, 2005
Messages
19,895
Brian the FollowHyperlink vba code is very simple
Application.FollowHyperlink strInput, , True
where strInput is the text string which contains the full path to the file.
The Browser method is more difficult and I would need to supply it in a database.
I can do that for you tomorrow.
 

BShick5088

Thread Starter
Joined
Jan 21, 2011
Messages
7
Thank you very much for your help.
I copied the code into the "on click" of a button and it doesn't seem to do anything...
 

OBP

Joined
Mar 8, 2005
Messages
19,895
Like I said you need to replace the part that says strInput with a Full path to a file like
"C:\Access\A-JCF-JCMRE.jpg"
 

BShick5088

Thread Starter
Joined
Jan 21, 2011
Messages
7
Ok.... I see how that works now, that's pretty cool. But really I need a user to be able to browse to a directory and pick a file to be hyperlinked. They should not have to drill this deep to set a link.

Here is the situation, I have a DB that contains project data for hundreds of projects. They want to now add a box on the form to hyperlink to a specific accounting PDF file that will be different for each project invoice. I want to have it work in such a way that all the user will will need to do is pick the blank field and the Insert-Hyperlink window pops up allowing them to browse to the file's location, pick it and insert it into the blank spot thus populating the table's data. This works now, but the user has to know to place the cursor in the box then pick the Insert drop menu then pick the Hyperlink menu pick then browse to the location. I just want to make it a little easier for the data entry person and future users...

Thanks again for your quick response,
Brian
 

OBP

Joined
Mar 8, 2005
Messages
19,895
Brian, I unsderstand what you are saying, I only showed you that to indicate how you can get and open documents.
You have a couple of problems with what you want to do, first there does not appear to be a VBA version of Insert Hyperlink, second you can't put it on the Double Click event, because you can't double click a hyperlink field. The first click initiates the hyperlink.
What I have provided uses an ordinary text field and the Follow Hyperlink method.
You need the the FilePath Table which holds the location of your Folder that contains your .pdf files. You will also need the Module called "mod_FileUtilities" which has the browsing VBA.
Here is how it works, when you move to the "hyperlink" field on the form for the first time it will open the browser to the folder that you have entered in to the "FilePath" table. Select your pdf file.
Once the "hyperlink" field has been populated when you click on it from anywhere else on the form it will follow the path and open the file just like a hyperlink field.
You could add that code to the "on Got Focus" event if you wanted so that if you tabbed in to a populated hyperlink field it would also open, but that might surprise a few users. :)

Another method you could use would be to load up any .pdf files in the target folder in to a table on database startup and then use a Combo box to select the one you want. That would also be quite efficient.
 

Attachments

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top