Populating a List box with files names

  • Thread starter Thread starter normad
  • Start date Start date
N

normad

I am using Access 97 and Windows 2000. I am trying to
populate a list box with the names of files in a specific
directory. I am fairly comfortable with Visual Basic. I
cannot use the FileSearch function because of the Access
97 and Windows 2000 combination. I can get a count of how
many files are in a directory, but I cannot get the code
correct to fill the list box. I am using the rowsource
but the box is still empty. I would appreciate any help
you can give me or any direction on where to go to look
for information.

Thank you,

Norma
 
Dim strFile As String
strFile = DIR(PATHNAME & "\*.*")
lstBox.RowSource = ""
Do Until strFile = ""
If strFile <> "." and strFile <> ".." Then
lstBox.RowSource=lstBox.RowSource & strFile & ";"
End If
strFile = Dir
Loop


Chris Nebinger
 
Chris:

Thanks! This works great.

Norma
-----Original Message-----

Dim strFile As String
strFile = DIR(PATHNAME & "\*.*")
lstBox.RowSource = ""
Do Until strFile = ""
If strFile <> "." and strFile <> ".." Then
lstBox.RowSource=lstBox.RowSource & strFile & ";"
End If
strFile = Dir
Loop


Chris Nebinger


.
 
Back
Top