You will need to set a reference in VBA to Microsoft Scripting Runtime and
Microsoft DAO 3.6
Here is some code that gets the file names in one folder, you will want to
do it twice to get both folders.
Sub try2()
Dim fso As Scripting.FileSystemObject
Dim theCurrentFolder As Folder
Dim curFiles As Files
Dim fileItem As File
Dim fname As String
Dim qry As DAO.QueryDef
Dim strQuery As String
Dim path As String
path = "path/to/folder"
'create an instance of the FileScriptingObject and assign it to the
variable fso
Set fso = CreateObject("Scripting.FileSystemObject")
'create an instance of the Folder object and assign it to the variable
theCurrentFolder
'pass the path of the folder as a parameter
Set theCurrentFolder = fso.GetFolder(path)
'now the Files collection of the folder object are exposed
Set curFiles = theCurrentFolder.Files
'create a query so you can run queries later
Set qry = CurrentDb.CreateQueryDef("", "Select * from tablename")
'iterate through the collection of file names...
For Each fileItem In curFiles
fname = fileItem.Name
'running a query to insert the filename into the table called TableName
strQuery = "INSERT INTO TableName(FileName) SELECT '" & fname & "'"
qry.SQL = strQuery
qry.Execute
Next
'clean up all files
Set fso = Nothing
Set theCurrentFolder = Nothing
Set curFiles = Nothing
Set fileItem = Nothing
Set qry = Nothing
End Sub
Please let me know if you need more assistance.