Solved

MS Access HyperLink Question

Posted on 2011-02-24
6
574 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

728 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