Well couple of approachs are available.
1. Use DIR() to loop through. Below is example to fill list/combobox.
Private Sub cmd_InputDir_Click()
Dim lcFiles As String
Me.txtInputDir = FolderBrowse.GetFolderName()
Me.txtInputDir.Requery
lcFiles = GetInputFileNames(Me.txtInputDir.Value)
Me.lst_Files.RowSource = lcFiles
Me.lst_Files.Requery
End Sub
Public Function GetInputFileNames(lcInPath)
Dim lcTempStr As String
Dim lvTempVar As Variant
lcTempStr = ""
lcInPath = lcInPath & "*.mdb"
' Returns filename with specified extension. If more than one *.ini
' file exists, the first file found is returned.
lvTempVar = Dir(lcInPath)
Do While lvTempVar <> "" ' Start the loop.
' Call Dir again without arguments to return the next *.dat file in the same directory.
If lcTempStr = "" Then
'1st item
lcTempStr = lvTempVar
Else
lcTempStr = lcTempStr & ";" & lvTempVar
End If
lvTempVar = Dir
Loop
If lcTempStr = "" Then
GetInputFileNames = "No DAT Files"
Me.lst_Files.Enabled = False
Else
GetInputFileNames = lcTempStr
Me.lst_Files.Enabled = True
End If
End Function
2. Use FileScripting Object. Sorry no good code examples. Most likely most efficient from code perspecitive. I would recommend using this over DIR() or DOS Bat file.
3. Create a DOS Batch file that executes a DIR command and sends results to a text file. Read the text file into a database table. Sorry can't find example... from what I recall, used Shell command to execute DOS Bat file. Then needed to add a few seconds delay to permit file to complete. Then read text file into database table.
htwh,
Steve Medvid
"IT Consultant & Web Master"
Chester County, PA Residents
Please Show Your Support...