J
Jeff
Short question: Will the FileDateTime function work in an Access
query? Or is there another way to read the Date Modified attribute of
a file from an Access query?
Long story: (descriptions and code are simplified with generic names
for clarity)
I'm trying to create a query to check whether all the documents in a
folder are up-to-date.
I have a database with a table of a large number of documents. The
table has a field "RevisionDate". The actual documents (in pdf
format) are in a folder that may be located anywhere (on the local
computer or on a server in another location). I created a custom
database property to hold the location of the Documents folder. To
open a document, I select the desired document from a listbox on a
form and concatenate the DocumentLocation and the DocumentName, e.g.:
----
Dim pdffile as string.
pdffile = [DocumentLocation] & "\" & [DocumentName]
Application.FollowHyperlink pdffile, , True
----
On the form, I can check the date of individual documents by reading
the Date Modified attribute of the file and comparing it to the
[RevisionDate] field.
----
pdfdate = Format(FileDateTime(pdffile), "Short Date")
If CDate(RevisionDate) > CDate(pdfdate) Then
MsgBox "Error - The selected document is outdated!"
End If
----
But I have to scroll through a long list to check each one, so I would
like to create a query to find all outdated documents. When I try to
use FileDateTime in the query, I get an error:
Undefined function "FileDateTime" in expression.
----
SELECT [Documents].[Record_ID], [Documents].[DocumentName],
[Documents].[RevisionDate], [DocumentLocation] & "\" & [DocumentName]
& ".pdf" AS PDFfile, CDate(Format(FileDateTime([pdffile]),"Short
Date")) AS pdfdate FROM [Documents] WHERE
(((CDate(Format(FileDateTime([pdffile]),"Short Date"))) <
CDate([RevisionDate])));
----
However it says on this page that you can use the FileDateTime
function in a query:
http://www.techonthenet.com/access/functions/file/filedatetime.php
I thought I might have something formatted incorrectly, so I have
tried simplifying the expression to just list the DateTime of the file
(as opposed to converting it to a Short Date format and comparing it
to the RevisionDate); but it still tells me that FileDateTime is an
undefined function.
So, can someone tell me if FileDateTime is a valid query function or
if it works only in VBA? And if not, is there another way to
accomplish what I'm trying to do? Thanks much.
query? Or is there another way to read the Date Modified attribute of
a file from an Access query?
Long story: (descriptions and code are simplified with generic names
for clarity)
I'm trying to create a query to check whether all the documents in a
folder are up-to-date.
I have a database with a table of a large number of documents. The
table has a field "RevisionDate". The actual documents (in pdf
format) are in a folder that may be located anywhere (on the local
computer or on a server in another location). I created a custom
database property to hold the location of the Documents folder. To
open a document, I select the desired document from a listbox on a
form and concatenate the DocumentLocation and the DocumentName, e.g.:
----
Dim pdffile as string.
pdffile = [DocumentLocation] & "\" & [DocumentName]
Application.FollowHyperlink pdffile, , True
----
On the form, I can check the date of individual documents by reading
the Date Modified attribute of the file and comparing it to the
[RevisionDate] field.
----
pdfdate = Format(FileDateTime(pdffile), "Short Date")
If CDate(RevisionDate) > CDate(pdfdate) Then
MsgBox "Error - The selected document is outdated!"
End If
----
But I have to scroll through a long list to check each one, so I would
like to create a query to find all outdated documents. When I try to
use FileDateTime in the query, I get an error:
Undefined function "FileDateTime" in expression.
----
SELECT [Documents].[Record_ID], [Documents].[DocumentName],
[Documents].[RevisionDate], [DocumentLocation] & "\" & [DocumentName]
& ".pdf" AS PDFfile, CDate(Format(FileDateTime([pdffile]),"Short
Date")) AS pdfdate FROM [Documents] WHERE
(((CDate(Format(FileDateTime([pdffile]),"Short Date"))) <
CDate([RevisionDate])));
----
However it says on this page that you can use the FileDateTime
function in a query:
http://www.techonthenet.com/access/functions/file/filedatetime.php
I thought I might have something formatted incorrectly, so I have
tried simplifying the expression to just list the DateTime of the file
(as opposed to converting it to a Short Date format and comparing it
to the RevisionDate); but it still tells me that FileDateTime is an
undefined function.
So, can someone tell me if FileDateTime is a valid query function or
if it works only in VBA? And if not, is there another way to
accomplish what I'm trying to do? Thanks much.