Solved

MS Access HyperLink Question

Posted on 2011-02-24
6
506 Views
Last Modified: 2012-05-11
I want to make a button that inputs the hyperlink.  I have been able to have it display the correct text but it doesn't actually have the hyperlink address in the properties.

Private Sub LinkToPDF_Click()
    Field_HyperLink.SetFocus
    Field_HyperLink.Value = "PDFs\" & [LIRi_Num] & ".PDF"
End Sub

Open in new window


Code works for display, but not as hyperlink.  How do I get the hyperlink address to populate.

The properties of this field: Data type is Hyperlink
0
Comment
Question by:dsheridan
6 Comments
 
LVL 75
ID: 34975718
Try setting the Text box property IsHyperlink to Yes ...

mx
Capture1.gif
0
 
LVL 3

Expert Comment

by:trbaze
ID: 34975857
Field_Hyperlink.HyperlinkAddress="PDFs\" & [LIRi_Num] & ".PDF"
0
 

Expert Comment

by:jameslaws
ID: 34975981
There is/are property/properties that you need to set as well to get the hyperlink to work. Check the properties and make sure everything is set properly.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 21
ID: 34976219
I have found that is is best to fully qualify the path. and not use a relative path like you are using.

I would use something like this:

"C:\myfolder\PDFs\" & [LIRi_Num] & ".PDF"

If you wan tit relative to the current database then try:

"CurrentProject.Path" & "\PDFs\" & [LIRi_Num] & ".PDF"


So you would use this for teh relative path to teh current database

Private Sub LinkToPDF_Click()
    
  Dim strPath as string

  strPath = "CurrentProject.Path" & "\PDFs\" & [LIRi_Num] & ".PDF"

    Me.Field_HyperLink =  "#" & strPath & "#" & strApth
End Sub

Open in new window



From years of experience with this I  find it better to not use a hyperlink data type with a PDF. I also use ShellExec API to open the PDF.

I have create this example to show how I recommend this:
Document Links 2
This is an update to the basic example of how to store the path to a file and also be able to view the file. You can browse using the standards windows common dialog to select the file. You can view the file using the application defined with the Windows File Associations. It uses the ShelExec API to open the file. It does not use the .Followhyperlink  method.

This example is a continuous form that could easily be used as a sub form to attach multiple documents to a record.

***** Because it doesn't use the hyperlink data type, this new version stores the path in a way that allows the folder to be easily moved.
0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 50 total points
ID: 34976224
Oops

try:

Private Sub LinkToPDF_Click()
    
  Dim strPath as string

  strPath = "CurrentProject.Path" & "\PDFs\" & [LIRi_Num] & ".PDF"

    Me.Field_HyperLink =  "#" & strPath & "#" & strPath
End Sub

Open in new window

0
 

Author Closing Comment

by:dsheridan
ID: 34979271
Great, Thank you.

The reason I want to use relative path names because it is in a network folder that is has a path of 150 characters.

I made a few modifications
I took out the current path and I disabled the last '& strPath string, because it was duplicating.
[code]
Dim strPath As String
strPath = "PDFs\" & [LIRi_Num] & ".PDF"
Me.Field_HyperLink = "#" & strPath & "#"       '& strPath
[/code]
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now