I have a public function in a module that returns the week number (see below):
Public Function Week(d)
Week = Format(DateValue(d), "ww")
'Debug.Print Week
End Function
and, I have a form with a calendar control (ActiveX).
When I pass the calendar control value (ocxCalendar.Value) to the Week() function, I get a type mismatch error.
Same error when I pass the control value (ocxCalendar.Value) to the Year() function.
Same error when I call Week(date) with no quotes in the intermediate window (e.g. week(5/7/07)), but it works if there are quotes (e.g. week("5/7/07"))
Oddly enough, I have a table with a date/time field and when I pass the field through the Week() and Year() functions in a query, I don't get any complaints.
I admit, datatypes tend to trip me up sometimes.
Any help would be appreciated.
Thanks.
Noel
Public Function Week(d)
Week = Format(DateValue(d), "ww")
'Debug.Print Week
End Function
and, I have a form with a calendar control (ActiveX).
When I pass the calendar control value (ocxCalendar.Value) to the Week() function, I get a type mismatch error.
Same error when I pass the control value (ocxCalendar.Value) to the Year() function.
Same error when I call Week(date) with no quotes in the intermediate window (e.g. week(5/7/07)), but it works if there are quotes (e.g. week("5/7/07"))
Oddly enough, I have a table with a date/time field and when I pass the field through the Week() and Year() functions in a query, I don't get any complaints.
I admit, datatypes tend to trip me up sometimes.
Any help would be appreciated.
Thanks.
Noel