Hi Jay,
It looks like you are correct about this being a sandbox issue. I was able
to get a correct file timestamp returned with Sandbox settings of 0 and 2,
but not with 1 and 3:
0 ---> Sandbox mode is disabled at all times
1 ---> Sandbox mode is used for Access applications,
but not for non-Access Applications
2 ---> Sandbox mode is used for non-Access applications,
but not for Access Applications (Default)
3 ---> Sandbox mode is used at all times
Reference:
http://support.microsoft.com/?id=294698
If you want to use a setting of 0 or 3, you can use what is known as a
wrapper function. Create the following function in a new module:
Function GetFileDateTime()
GetFileDateTime = FileDateTime("d:\FileName.txt")
End Function
Set the control source for your text box as follows:
=GetFileDateTime()
Since your example is hard-coded, you might actually want to use a more
flexible function. If the form's recordset includes a field named
"FileName", which specifys the complete path (path + filename.txt), then
you can pass this as a parameter to the function. In this case, change the
function to this:
Function GetFileDateTime(FileName As String) As String
On Error GoTo ProcError
GetFileDateTime = FileDateTime(FileName)
ExitProc:
Exit Function
ProcError:
Select Case Err.Number
Case 53 'File not found
GetFileDateTime = "File not found"
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure GetFileDateTime..."
End Select
Resume ExitProc
End Function
and change the control source to:
=GetFileDateTime([FileName])
Tom Wickerath
Microsoft Access MVP
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
Jay said:
FileDateTime is not working with 2002 and 2003. Looks like
a sand box mode problem. I have Jet Engine 4 service pack 8
installed and still no go.
I placed in a control on my form =FileDateTime("d:\FileName.txt")
Just says error.
Any solutions with this? Any hope of getting it to work?