Ok I got some progress... I think.
There's one line missing from the function above, which is the mid function to split the date from the rest of the filename, but other than that it's the same:
Code:
Public Function Foo(InVal As String) As IntegerDim MyArray() As String
Dim MyDate
Dim FileDate
FileDate = Mid(InVal, InStrRev(InVal, " ") + 1, InStrRev(InVal, ".") - InStrRev(InVal, " ") - 1)
MyArray = Split(FileDate, "-")
MyDate = DateSerial(MyArray(0), MyArray(1), MyArray(2))
Foo = DateDiff("d", MyDate, Date)
End Function
When going back to design view for the query, I have "Expr1: Foo([Attachments.FileName])". I'm getting the exact same output. I get numbers, but when I put ">2" under Criteria I get a data type mismatch. What am I missing?