Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am modifying an Access file created by someone else. Displayed on the form screen is a place where the date of a DOS file is supposed to be displayed using the expression: GetModDate("N:\Personnel\HR_Report.txt")

    The file is located in that location but it is like Access does not understand the expression and displays 12/30/1889 instead of 2/2/2009.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    Hi Judy,
    I don't believe that GetModDate() is a VBA function. I think instead what you want to do is to define the file as an object in VBA and then use the DateLastModified property. Look at the example in VBA help for that property - it shows you what is needed.

    PS: It is possible that GetModDate() is a user defined function that exists in the database you are working on and does use the property.
    Wendell

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found the following function: GetModdate = CreateObject("Scripting.fileSystemObject").Getfile (filepath).dateLastmodified

    However when the form loads, I get a runtime error 53 "File Not Found".

    I looked up DateLastModified in the help file but could not quite understand how to use it.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    To do that sort of thing you use VB Script to get the file properties, and that's what the line of code you found is the start of. (You can find more about doing that sort of thing on MSDN.) However there should have been several other lines of code as well. Paraphrasing the VBA Help:
    Code:
    Sub ShowFileAccessInfo(filespec)
    	Dim fs
    	Dim f
    	Dim s
    	Set fs = CreateObject("Scripting.FileSystemObject")  ' Create the File System Object
    	Set f = fs.GetFile(filespec)  ' Get the File attributes for the path specified in filespec
    	s = UCase(filespec) & vbCrLf  ' set the string s to the path and file and a newline
    	s = s & "Created: " & f.DateCreated & vbCrLf  ' Append the date created from the attributes object to s
    	s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf  ' append the date last accessed to s
    	s = s & "Last Modified: " & f.DateLastModified   ' append the date last modified to s
    	MsgBox s, 0, "File Access Info"   ' display the info in a message box
    End Sub
    It appears that the line that does that should in principal work - if the function has the proper variables defined. I would break it down into several lines as the help example suggests to see where things are going south. In the example, you would have a statement setting the text box on the form to f.DateLastModified.
    Wendell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •