Solved

Hyperlink to pdf on local drive

Posted on 2014-03-05
6
387 Views
Last Modified: 2014-03-07
Hi,

(I raised this last week and never fully resolved it).

1. I have a form with a hyperlink in it.

2. I then use the form to enter a link to a local pdf file.

3. After this I click on the link and the pdf should open.

In the database attached.
Please use the form to insert a PDF file from your local drive onto the hyperlink.

Then save the record, and then see if you can click on the hyperlink.
Can you get the pdf to open. (Same applies with other formats)

Why can't I open my pdf when I click on the link?


PS: The VBA was supplied by an expert and ALMOST does exactly what I want.
dbselectfile.accdb
0
Comment
Question by:Patrick O'Dea
  • 3
  • 3
6 Comments
 
LVL 34

Expert Comment

by:PatHartman
ID: 39907607
I can't download the file where I am.

I never use the hyperlink data type since it isn't supported by SQL Server.  I use a standard text column.  In code, I use the FollowHyperlink method which will use Windows to determine which application to launch based on registry settings and open the correct application.  So if the file extension is .xls, Excel will open, if it is .txt, notepad will open, if it is .doc, Word will open.  If it is a web address, a web page will open up.  To make it look like a hyperlink, set the Display as Hyperlink property to Always on the property sheet.
0
 

Author Comment

by:Patrick O'Dea
ID: 39907779
Thanks Pat,

I am looking at FollowHyperLink .. it's new to me!

Is it possible to set a textbox = Application.FollowHyperlink strInputByUser??

... I am little beyond my comfort zone.

Ideally, if someone could download my database and tweak it!
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 39907979
No, you would reference another text box if you wanted the user to specify.

Application.FollowHyperlink Me.InputByUser

Here is a code sample taken from an application where I use it.  The form is bound so I save the current record first if it is dirty.  These are links I stored internally and I do not store the path with the file name for this application because I want to make it easy for the client to move the directories to a different location.  So, the code concatenates the path with the document name from the text box.

Private Sub cmdOpenDoc_Click()
    Dim strInput As String
    
On Error GoTo Err_cmdOpenDoc_Click
    If Me.Dirty Then
        DoCmd.RunCommand acCmdSaveRecord
    End If

    If Right(Me.ScannedDocPath, 1) = "\" Then
        strInput = Me.ScannedDocPath & Me.txtFullDocName
    Else
        strInput = Me.ScannedDocPath & "\" & Me.txtFullDocName
    End If
    
    Application.FollowHyperlink strInput, , True

Exit_cmdOpenDoc_Click:
    Exit Sub

Err_cmdOpenDoc_Click:
    Select Case Err.Description
        Case 2501
            Resume Next
        Case 490    '   cannot open file
            MsgBox "This file cannot be found.  Please check its name and path.", vbOKOnly + vbInformation
            Exit Sub
        
        Case Else
            MsgBox  Err.Number & "--" &  Err.Description
            Resume Exit_cmdOpenDoc_Click
    End Select
    
End Sub

Open in new window

0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:Patrick O'Dea
ID: 39909999
Thanks for advice ..

I have tried the VBA provided and some other stuff too.
I am coming across a number of problems ...
A whole variety of issues arising and I am losing my enthusiasm!


Would it be possible to send me a very simple db with a hyperlink facility.
0
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 39910204
Use the ... button to select any registered file type.  Then click the Open button to open it.   It will even work to open web pages if you use the full name ---

http://www.fmsinc.com/
HyperLinkSample140306.zip
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 39912919
Pat,

Thanks for that.
It works very well.

(Now, I have to make sure that I don't break the golden rule! - I must try to understand the VBA - or at least most of it).
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

895 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

19 Experts available now in Live!

Get 1:1 Help Now