Is there a way in access to dynamically create a list of files names located
in a specific directory?
Thank you,
Silvio
The following will fill a List Box row source with the names of all
files in a specific folder. Place it in an event on a form to fill a
list box on that form. Change MyFolderName and ListBoxName to whatever
the actual names are.
Public Sub FillListBox()
On Error GoTo Err_Handler
Dim Db As DAO.Database
Set Db = CurrentDb
Dim intX As Integer
Dim MyPath As String, MyName As String
MyPath = "C:\MyFolderName\"
MyName = Dir(MyPath, vbNormal)
Do While MyName <> ""
intX = 1
If InStr(MyName, ".") > 0 Then
Me!ListBoxName.RowSource = Me!ListBoxName.RowSource _
& MyName & ","
End If
MyName = Dir
Loop
If intX = 0 And MyName = "" Then
MsgBox "Nothing found"
Exit Sub
End If
ListBoxName.RowSource = Left(ListBoxName.RowSource, _
Len(ListBoxName.RowSource) - 1)
Exit_Sub:
Exit Sub
Err_Handler:
MsgBox "error # " & Err.Number & " " & Err.Description
Resume Exit_Sub
End Sub