Are you talking about a disconnected recordset, or do you actually want to
add the files to a table in your database?
For the latter, I'd do something like the following untested air-code (which
uses DAO, because that's what I always use with Jet databases):
Dim dbCurr As DAO.Database
Dim rsCurr As DAO.Recordset
Dim strFile As String
Dim strFolder As String
strFolder = "C:\MyData\" ' Note that the closing slash is important here
Set dbCurr = CurrentDb()
Set rsCurr = dbCurr.OpenRecordset("SELECT Folder, File FROM MyTable")
strFile = Dir(strFolder & "*.*")
Do While Len(strFile) > 0
With rsCurr
.AddNew
!Folder = strFolder
!File = strFile
.Update
End With
strFile = Dir
Loop
rsCurr.Close
Set rsCurr = Nothing
Set dbCurr = Nothing
On the other hand, I'd probably just use an INSERT query, rather than a
recordset:
Dim strFile As String
Dim strFolder As String
Dim strSQL As String
strFolder = "C:\MyData\" ' Note that the closing slash is important here
strFile = Dir(strFolder & "*.*")
Do While Len(strFile) > 0
strSQL = "INSERT INTO MyTable (Folder, File) " & _
"VALUES('" & strFolder & "', '" & strFile & "')
CurrentDb.Execute strSQL, dbFailOnError
strFile = Dir
Loop
I don't normally use disconnected recordsets, so it would take me a little
longer to cobble together an example, but hopefully the first sample above
gives you the general idea.