Solved

Help with listbox issue

Posted on 2013-01-29
5
295 Views
Last Modified: 2013-01-30
About a week ago an expert helped me with a question that involved having the ability to open PDF files from a form.  I want to take this a little bit further and have the user have the ability to open a PDF file, by double clicking the record in a listbox.  Please see the attached Access file.  Note that only PDF files will ever be used with this database.

The way I see this working is this...

1)  A program administrator would add the files/records to the database via the use of the form, "frmLinkedPDF".  These files in real use would be on a network server but for now for testing I'm just using a folder on my computer.

2)  Then the end user would use the form "Form1" to select the PDF file they want to open/view/print.  They would do this by double-clicking the item in the listbox.

I need help with the doubleclick event of the listbox.

--Steve
PDF-Attachment-Example.accdb
0
Comment
Question by:SteveL13
  • 3
5 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38830917
I cannot open your attachment, company policy, but I would use the FollowHyperlink method.  Assuming that the listbox displays the path\name of the file, I would use the double click event of the list and put the following code in that event:


    Application.FollowHyperlink  me.YourListControlName
0
 

Author Comment

by:SteveL13
ID: 38830958
I entered...

    Application.FollowHyperlink Me.List0

in the on doubleclick event of the listbox but it doesn't work.

Here is what happens:

1) I get a message popup indicating that a potential securoty concern has been identified. Hyperlinks can be harmful....etc.   (I wouldn't want this to appear)

2) It also reads "Do you want to continue?  When I click [Yes] I get runtime error 490 - Cannot open the specified file.

???
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 38831002
use Shell


Private Sub List0_DblClick(Cancel As Integer)
Dim strPdf As String
strPdf = Me.List0.Column(2)
Shell "C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Acrobat.exe " & strPdf, vbNormalFocus
End Sub
0
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 250 total points
ID: 38831463
The Followhyperlink method works fine for me running Access 2007 on Windows 7 platform.

The "cannot open the specified file" error is an indicator that the value in the listbox is not the full path to the file.

It looks like capricorn1 was able to open your file and found that the filename is in the third column of your listbox, so try:

Application.Followhyperlink me.list0.column(2)
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38835713
Glad to help.  So, which method did you go with?  The advantage of the FollowHyperlink method is that it will open the file in the default application associated with that file type.
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

Suggested Solutions

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…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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, when working with VBA, learn some techniques for writing readable and easily maintained code.

777 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