import from dated subdirectories

J

jennifer.standley

Hi, I've seen posts with examples of how to loop through files in a
single folder, but I am dealing with the same dbf file name in
multiple subdirectories. These subdirectories are named for the date
they were created - 20081112 for example. In this example, the file
path to the specific dbf we need to import is: H:\QS
\20081112\FileName . There are other subdirectories also in QS

How could we loop through the dated subdirectories to get this file to
speed up the import process and is there a way to setup a stored
procedure to get the most recent (that day's) dated subdirectory only
as an automated import?

Thank you for any help you can give!

Jennifer
 
K

Klatuu

There are no stored procedures in Access or Jet, but what you want to do
should not be that hard.
Assuming the date portion of the name would never be later than the current
date, here is a trick that will give you the most recent date starting with
today's date:

Private Function NewestDir() As String
Dim strDir As String
Dim dtmCheckDate As Date

dtmCheckDate = Date

Do While True
If strDirName = "H:\QS\" & Format(dtmCheckDate,"yyyymmdd",
vbDirectory) = vbNullString Then
dtmCheckDate = DateAdd("d", -1, dtmCheckDate)
Else
Exit Do
End If
Loop

NewestDir = strDir
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top