[AccessD] Retrieving filename and modified date

Stuart McLachlan stuart at lexacorp.com.pg
Wed Aug 27 10:03:24 CDT 2003


On 27 Aug 2003 at 14:04, Jeffrey Majchrzak wrote:

> I am working on a project where I need to scan a folder daily to see if 
> any new files have been added.  This folder can contain many files but I 
> am looking for only the files that start CLMS then have a date.  Example 
> CLMS082603.xls.  I need to capture the date in the file name and the 
> modified date of the file and save it in a table.  Is this possible?  
> Could you please provide code examples of how I would go about doing this? 
> 

Air code, so it will probably need some modification and addition of 
errorchecking, but here's a DAO version:

Private Function GetNewFiles(Directory as String) as Long
Dim rs as Recordset
Dim strCriteria as String
Dim strTemp as String
Dim strDate as String

Set rs = CurrentDB.OpenRecordset("myTable")

strTemp = Dir$(Directory & "CLMS??????.xls"

While strTemp > ""
    strDate = mid$(strTemp,Len(strTemp) - 10,6)
    strCriteria = "fldDate = '" & strDate & "'"
    rs.Findfirst, criteria
    if rs.Nomatch Then
       rs.addnew
       rs!fldDate = strTemp
       rs!fldModTime =  FileDateTime(Directory & strTemp)      
       rs!Update
    End If
    strTemp = Dir$
Wend

End Function

 
-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System 
Support.





More information about the AccessD mailing list