I have the following module to get the # of Thursdays in a given period of time.
This works fine in a query, with the following column as an expression:
But I don't want this column in the query as it becomes part of a Union query...and this column creates extra results in any year which does not have 52 Thursdays.
However, if I try to put this function in the report itself I get a #Name error.
Is there a way to get this into the report without having it in the query construction?
Thanks.
Tom
Code:
Function RetThur(dteStart As Date, dteEnd As Date)
Dim i As Integer
Dim intT As Integer
Dim dteTest As Date
Dim ny As Date
Dim xm As Date
On Error GoTo RetThur_Error
If dteStart >= dteEnd Then
'Problem
RetThur = "Error"
End If
For i = 0 To (dteEnd - dteStart)
dteTest = dteStart + i
ny = DateSerial(Year(dteTest), 1, 1)
xm = DateSerial(Year(dteTest), 12, 25)
If Weekday(dteTest) = 5 And dteTest <> ny And dteTest <> xm Then
intT = intT + 1
End If
Next
RetThur = intT
On Error GoTo 0
Exit Function
RetThur_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure RetThur of Module modGetThursdays"
End Function
This works fine in a query, with the following column as an expression:
Code:
RetThur(Forms!frmDateSelector!txtStartDate,Forms!frmDateSelector!txtEndDate)
But I don't want this column in the query as it becomes part of a Union query...and this column creates extra results in any year which does not have 52 Thursdays.
However, if I try to put this function in the report itself I get a #Name error.
Is there a way to get this into the report without having it in the query construction?
Thanks.
Tom