This assumes the files are named as you specified in your original post where
20060317.mdb would be today. If there are other characters before the date,
you will need to strip them off to do the compare.
This routine uses the Dir function to loop through all mdb files in the
specified directory and compare their names to the begin and end date names.
If the name is within the range, it does the transfer (I did not include that
code, but I show where it goes), if it is not, it is bypassed.
I don't know the names of the controls on your form where you enter the
start and end dates, so I made some up. You will need to change them to
match your names.
I also included a counter so the user will know How many files were imported.
Dim strStartDate as String
Dim strEndDate as String
Dim intImportCount as Integer
strStartDate = Format(Me.txtStartDate, "yyyymmdd") & ".mdb"
strEndDate = IIf IsNull(Me.txtEndDate), _
Format(DateAdd("d", -1,Date), "yyyymmdd") & ".mdb", _
Format(Me.txtEndDate, "yyyymmdd") & ".mdb")
'Path to use should be the path to the mdb files & *.mdb
'Example
'E:\WhereTheFilesAre\*.mdb
NextMdb = Dir(PathToUse, vbDirectory) ' Retrieve the first entry.
'If no mdb files are in the directory, int will return "" and the loop will
never happen
Do While NextMdb <> "" ' Start the loop.
If NextMdb >= strStartDate and NextMdb <= strEndDate Then
'Here is where you do the import
intImportCount = intImportCount + 1
End If
NextMdb = Dir ' Get next entry.
Loop
MsgBox "Imported " & Cstr(intImportCount) & " Files"
Yes the mdbs are all in the same directory.
[quoted text clipped - 26 lines]