Type mismatch with dates

Noel

Registered User.
Local time
Today, 00:02
Joined
Apr 13, 2007
Messages
61
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
 
addition info

when the form and textboxes are unbound, then the functions work!

THanks in advance for your input.

Noel
 
So what datatype are the fields you are trying to store the data in the table for the bound fields that work when they are unbound.
 
numbers

in the table the fields are:
year
week

and both have data type = number (long integer)
 

Users who are viewing this thread

Back
Top Bottom