Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CboBox Row Source as Diretory & Open PDF 2

Status
Not open for further replies.

pdldavis

Technical User
Oct 29, 2001
522
0
0
US
Hi, with many thanks to a post by Rollie a while back I was finally able to complete this and thought I'd pass it along:

How to change a combo box row source to list .pdf files in a directory and then open those .pdf files.

1. Create combo box. In this case it is named CboFiles. Leave RowSource blank. Change Rowsource type to Value. Don't forget to set a field width.
Bound Column = 1

2. In the combo Box OnEnter Event, paste the following:

Dim MyFile As String, Stsql As String

MyFile = Dir("C:\PDFs\Mech\*.*")
Stsql = MyFile & ";"
Do While Not (MyFile = "")

MyFile = Dir

Stsql = Stsql & MyFile & ";"
Loop

Me.CboFiles.RowSource = Stsql


2. Paste the following into the combo box AfterUpdate Event:

FollowHyperlink "C:\Pdfs\Mech\" & Me.CboFiles


Hope that helps someone out.

 
This code rocks! Note for newbies: works for any type file, not just .pdf's.

Thanks pdldavis. Have a star.
BTW - this should be an FAQ.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top