Solved

Help with listbox issue

Posted on 2013-01-29
5
292 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 119

Accepted Solution

by:
Rey Obrero 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

760 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

21 Experts available now in Live!

Get 1:1 Help Now