use the "DIR" command
This code works I just made it
make a new button on your form and paste this VBA coe in the Event Procedure.
----------------------------------
Dim Rs1 As ADODB.Recordset
Dim SQLCode As String
Set Rs1 = New ADODB.Recordset
SQLCode = "Delete from [txt-doc Files];"
Rs1.Open SQLCode, CurrentProject.Connection
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
'Debug.Print MyName ' this is a folder if you want it
ElseIf Right(MyName, 4) = ".txt" Or Right(MyName, 4) = ".doc" Then
Debug.Print MyName ' these are the files
SQLCode = "INSERT INTO [txt-doc Files] ( Filenames ) SELECT '" & MyName & "' AS Expr1;"
Rs1.Open SQLCode, CurrentProject.Connection
End If ' it represents a directory.
End If
MyName = Dir ' Get next entry.
Loop
Set Rs1 = Nothing
Set Conn2 = Nothing
'refresh combo box
Me!Combo1.Requery
------------------------------
a few things to note:
you need to create a table called "txt-doc Files" spelled exactly that way.
you need to make one field in the table called "Filenames" with a text type and 255 field size, to allow for very long file names.
The combo boxes "Row source" property must be this
SELECT [txt-doc Files].Filenames FROM [txt-doc Files];
Like I said it works
DougP, MCP