Share via

Access 2010 - FileDateTime Function returns #Name?

Anonymous
2012-01-25T17:30:09+00:00

I have a Access 2003 database that uses the FileDateTime function.  When I open the database in 2003 the function works perfect.  However, when I open the database in 2010 I get #Name? as the result.

When I look in the Expression builder, I do not see this function in the list of All Functions.  But I see a website that says that it works in 2010.

Am I missing the reference to the library with this function?  What Library contains the function?

FYI - I am testing this with a file on my C:\ drive so I know I have access to the file.

Please help.

Thanks,

Terry

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
2012-01-25T20:37:27+00:00

In recent versions of Access, you can't use FileDateTime directly in an expression, it is considered to be "unsafe". You can use it in VBA code though.

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

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

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?

0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2012-01-25T22:37:31+00:00

    Thank you, Hans.

    Was this answer helpful?

    0 comments No comments
  2. HansV 462.6K Reputation points
    2012-01-25T22:35:36+00:00

    I don't know of a list specifically for Access 2010, but as far as I know the information in http://support.microsoft.com//kb/294698/en-us still applies.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2012-01-25T22:19:21+00:00

    Hans - would you know of a list of similar "unsafe" native functions in Access 2010? It would be something rather important to have.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2012-01-25T22:05:22+00:00

    Excellent!! Worked Perfect. Thank you!!

    Was this answer helpful?

    0 comments No comments