1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

MS Access 2003 - Hyperlink a field

Discussion in 'Business Applications' started by BShick5088, Jan 21, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. BShick5088

    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
     
  2. karlhaywood

    karlhaywood Account Closed

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

    Application.FileDialog(msoFileDialogOpen).Show
     
  3. BShick5088

    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
     
  4. OBP

    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.
     
  5. BShick5088

    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
     
  6. OBP

    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.
     
  7. BShick5088

    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...
     
  8. OBP

    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"
     
  9. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
  10. BShick5088

    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
     
  11. OBP

    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.
     

    Attached Files:

  12. BShick5088

    BShick5088 Thread Starter

    Joined:
    Jan 21, 2011
    Messages:
    7
    Thank you again for all your help...
    I hope you have a good week,
    Brian
     
  13. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/976030

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice