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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listing Files in a Directory 1

Status
Not open for further replies.

vvilan

Technical User
Jul 29, 2008
16
US
Hi, how do you list all the files in a directory in MS access using VBA? Preferably in a list or combo box.

thanks in advance!
 
There's a few ways. You can try this on a button or as is on the OnLoad event. Change Row Source type to Value list.
Private Sub Form_Load()
Dim LoadFiles As String
Dim strFill As String
LoadFiles = Dir$("c:\dev\*.*")
Do While LoadFiles > ""
strFill = strFill & LoadFiles & ";"
LoadFiles = Dir$
Loop
lstFiles.RowSource = strFill
End Sub
 
I changed the row source type to value list and added this method to the load event and replaced lstFiles with my listbox's name as well as changed the path to currentProject.path & "\
 
** Posted too quickly, and it still doesn't work
 
Never mind, it works perfectly thank you very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top