Results 1 to 8 of 8
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is online now Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,096

    FileDateTime equivalent for folders?

    FileDateTime gives me the date last modified for a file. Is there an equivalent method for obtaining the date last modified for a folder? I.e., were any of the files in a given folder added, deleted or otherwise changed? Somebody have a sub laying around for such a question?



    I did see a post using FSO on an Excel site, but thought perhaps I'd missed something native to Access.

    This works, unless someone has something better that's native to Access?
    Code:
    Option Compare Database
    Option Explicit
    Private Sub testfldr()
    MsgBox GetDateLastModif("c:\TMS")
    End Sub
    Function GetDateLastModif(strFold As String) As Date
       Dim fso As Object, gf As Object
       Set fso = CreateObject("Scripting.FileSystemObject")
       Set gf = fso.GetFolder(strFold)
       GetDateLastModif = gf.DateLastModified
    End Function

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I tested FileDateTime() on a folder and it returns a date/time as well.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I presume you got that code from here (or somewhere that got it from here)
    https://stackoverflow.com/questions/...rrent-date-vba
    I don't see anything about that that would indicate it's for Excel?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is online now Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,096
    Oops! I think because there were several posts in the Excel realm I had Excel on the brain :-(

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Even if it was Excel specific I imagine you could use properties/methods as long as you had a reference to the Excel library in your Access code project. I say that because I have worked with Excel objects from Access via Automation (I think that has a new name now?).
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is online now Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,096
    Yes, I had just tried that myself and found that if I only give the function a folder I get the DLM of the folder. (I also tested with the trailing "" on the folder but both that and "\*" will fail.)

  7. #7
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    so what if you pass the text string and then inside your function, make sure it doesn't have those characters that cause your code to fail? Just use a text function to strip the offending characters or patterns out of your string.

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is online now Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,096
    You misunderstood my post in reply to post #2. I was essentially affirming June7.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. FileDateTime Function
    By Dave_D in forum Modules
    Replies: 1
    Last Post: 08-01-2016, 01:18 PM
  2. Replies: 2
    Last Post: 05-24-2016, 04:54 PM
  3. Hyperlink to network folders
    By smannon in forum Forms
    Replies: 1
    Last Post: 10-24-2011, 02:42 PM
  4. Replies: 3
    Last Post: 01-25-2011, 09:50 AM
  5. Import from various folders
    By Statique in forum Import/Export Data
    Replies: 2
    Last Post: 07-02-2009, 06:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums