Share via

Access 2010 - undefined filedatetime function error 3085

Anonymous
2011-11-14T22:36:38+00:00

I just upgraded from Access 2003 to Access 2010.  When using the FileDateTime function, I receive an error message "undefined function 'FileDateTime' in expression".  I use this function to get the last modified date of an external text file.

I found no missing references.

Does anyone have a solution or workaround?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2011-11-14T22:52:17+00:00

In recent versions of Access, you can't use FileDateTime directly in an expression.

You could create a custom function to act as "wrapper":

Function GetFileDateTime(FileName As String) As Date

    GetFileDateTime = FileDateTime(FileName)

End Function

and use it like this in an expression:

=GetFileDateTime("C:\Access\MyDatabase.mdb")

Alternatively, you can fill a text box using code, for example:

Me.txtFileDate =  FileDateTime("C:\Access\MyDatabase.mdb")

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2011-11-15T15:01:27+00:00

You could use this version:

Function GetFileDateTime(FileName As String) As Variant

    On Error GoTo ErrHandler

    GetFileDateTime = FileDateTime(FileName)

    Exit Function

ErrHandler:

    ' Something went wrong, return Null

    GetFileDateTime = Null

End Function

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-11-15T18:09:56+00:00

    Perfect!!  Thank you.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-11-15T14:39:11+00:00

    The code works great as long as there is a file to be found.  

    However, I get a 'run-time error 53 file not found' when the target file does not exist.   Could you suggest code to exit the function and/or return to the field a null value?  Thank you.

    Was this answer helpful?

    0 comments No comments