Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WeekDay function is malfunctioning 1

Status
Not open for further replies.

Dor100

Technical User
Apr 9, 2001
279
US
The WeedDay function has begun to malfunction (Acc XP on Novell client for Win 2k). It is now producing a "Type mismatch" error despite having worked previously. When I use the IsDate function to confirm that the date argument is indeed a date, it returns True, e.g.:

MsgBox IsDate([Form_TheForm].CalendarDate) 'returns "True"

If IsDate([Form_TheForm].CalendarDate) Then
MsgBox WeekDay([Form_TheForm].CalendarDate, 1)
End If

My references are unchanged and have been in use for a long time. I've also tried appending "#'s" around the date with ampersands, using both a variant and date variable for the date, the "Me." prefix, and nesting the WeekDay within WeekDayName. This should not be occurring. Any ideas? Thanks.
 
And what about this ?
MsgBox WeekDay(CDate([Form_TheForm].CalendarDate), 1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Been trying many variations, such as quotes, #'s, etc., but still receiving at most the same type mismatch error.
 
And this ?
MsgBox VBA.WeekDay(CDate([Form_TheForm].CalendarDate), 1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Might perhaps also consider the CVDate() function, see International Dates in Access - I'm referring to section 3, at the bottom.

Also, do use a [tt]msgbox me!calendardate.value[/tt] to ensure there really is a recognizable date within the control. I've never been a fan of using that way of referring to forms (unless I'm instantiating several instances of the same form). For the current form I'll always reference through Me, else I'm referencing through the forms collection, i e Forms("TheForm").controls("TheControl").value

Roy-Vidar
 
That's working both with and without the CDate. Thanks a lot.
 
My last reply posted before RoyVidar (nice to see you again and thanks for posting) appeared - the reply was to PHV. Nonetheless I intend to carefully check out RV's material and post my results. It would be very interesting to know why this has been suddenly occurring to begin with as well...
 
Seems you have used the reserved word weekday somewhere to name something ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank God for this remarkable forum and a number of extremely helpful people who post here. What you've suggested is true. Interestingly, F1 was useless for the VBA.* prefix, so it's a bit like a buried treasure. Thanks again, PHV, and thanks to everyone behind Tek-Tips. Still need to check out RV's items...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top