Solved

MS Access HyperLink Question

Posted on 2011-02-24
6
560 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

726 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