Solved

Help with listbox issue

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

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…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

733 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