How do I get a form to display files in a director (MS Access 2000)

I have an application that reads text file of the NYS Budget Bills and appends to a table all the items for a particular fund. Currently the user has to enter the drive and path to the file. I would like to create a listbox of all the '*.txt" files in a directory. Does anyone know how I can search a directory to obtain the file names. I have looked at the Application.FileSearch object but the 'FoundFiles' property is only valid for Office and not Access. <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

This is what I was trying to do:

Set fs = Application.FileSearch
With fs
fs.LookIn = "J:BSMemItemsdb"
.fileName = "*.txt"
If .Execute > 0 Then
For i = 1 To fs.fileName
Me.lstBxFile.Column(0, i - 1) = .foundfiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With

Thank you

Don
<img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

Re: How do I get a form to display files in a director (MS Access 2000)

FileSearch is available in all Office applications, including Access. I have Access 2002, and it is available "out of the box" there. Perhaps you must set a reference to the Microsoft Office 9.0 Object Library in Access 2000 to make it work (in Tools | References...), but that is just a wild guess. Perhaps somebody wh uses Access 2000 can react. Your code contains an error, though. For i = 1 to fs.FileName is not valid, since FileName is a string, not a number. Instead, use

Re: How do I get a form to display files in a director (MS Access 2000)

I've been having problems with FileSearch on a couple of machines. The code doesn't error, but FoundFiles always returns 0 even though someone else can use the exact same code on their machine and get the correct results. I've seen it on both A2k and AXP and on WinXP and Win2k. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15> It must be ME!! <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>