Solved

Help with listbox issue

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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 …

919 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

18 Experts available now in Live!

Get 1:1 Help Now