Solved

MS Access HyperLink Question

Posted on 2011-02-24
6
576 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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