PDA

View Full Version : A Simple Request - Show files in a list box



Mavver
07-26-2007, 05:14 AM
Hello all

I hope that is a simple question, it sounds like it.

What I want to happen is to have a LIST BOX showing all the files within a specific folder on the server.

The user will then have the option to select one or more files and then open them from access.

Any help, or link to a resource on the web would be most helpful, and gratefully recieved.

Ta muchly

Mav

mattj
07-26-2007, 05:45 AM
See here: http://www.blueclaw-db.com/listbox-directory.htm for how to display the files, and here: http://support.microsoft.com/kb/q148632/ for how to use the SHellExecute API to open the file.

HTH
Matt

Mavver
07-26-2007, 07:37 AM
Thanks Matt,

I got the list box up and running and called it lstGreyFiles,

The list box brings up such names as filelist.xls and filelist.doc

I tried to put together a way of stringing together the file name (as selected from the list box) to enable the shell to work. It failed.

Can someone cast an eye over this code to see where I am going wrong?

The error that pops up is ...File Not Found


Dim varItemGrey As Variant
Dim strCriteriaGrey As String

If Me.lstGreyFiles.ItemsSelected.Count = 0 Then
'a Message box will appear saying that nothing has been selected

Else

For Each varItemGrey In Me!lstGreyFiles.ItemsSelected
strCriteriaGrey = "F:\schoolfood\" & Me!lstGreyFiles.ItemData(varItemGrey)
Next varItemGrey

End If

Shell "strCriteriaGrey"