Discussion Locked

WeekDayName

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am trying to get the name of the day of the week on a form which already holds the date. I can get the number of the day within the week using the function WeekDay, and on the result of this I want to apply the function WeekDayName. This works in VB, but not in the Expression builder. I cannot use VB because I have a continuous form and so get the same day name for all dates, i.e. the name of the day corresponding to the last date focussed.
I need a way to apply WeekDayName in the expressionbuilder or a way to write VB for one detail only of a continuous form.

5 replies

by seagull data services

Use the weekday function and select case statement in the underlying query (create one if you're not using one) of the form.
Public function DayName(dtDate as Date) as string
select case weekday(dtDate)
Case 1
DayName="Monday"
Case 2
'etc
Case else
DayName = "Oh Shit!"
end select
end function

if that doesn't work try using the iif (immediate if) function as the control source of the text box you want to display the day name.

Hope this helps
John

This discussion is closed to new replies.