Hi There
I have a function that does some calculations depending on the 2 date
arguments passed into it:
Function GetPeriods(dteStart As Date, dteEnd As Date) As Integer
The function has 2 more arguments but they are not causing the problems I'm
encountering.
The 2 date arguments are used to build a dynamic SQL statement for a
recordset. If the date in the query doesn't match the dteStart it must find
the date in the query closest to this date without going over it, I did this
by using the DLast function
dteStart = DLast("[DateStart]", "qryPeriods", "[DateStart]<=#" & dteStart &
"#")
The DLast function works fine until I pass through a date earlier than the
earliest date in the table, Invalid use of null error.
I want to do the same sort of thing with the second argument, dteEnd, but to
find the same date or a later date from the query than the dteEnd argument
or find the last date if the dteEnd is greater than the last date in the
query. To complicate things more the dteEnd looks in a totally different
date field called DateTo. A period has a StartDate and an EndDate so the
need for the 2 separate date fields.
Can somebody guide me in the right direction in how to find these dates?
Stewart