Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS Access HyperLink Question

Posted on 2011-02-24
6
Medium Priority
?
587 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
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 200 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

670 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