G
Guest
So far I have wasted over 3 hours on this silly problem. I have a report
that is a monthly calendar display - a box for each day. To determine which
day date to put in which box I find out the weekday of the first of the
month. If it is Sunday (weekday 1) I put "1" in the first box (Weeks are
displayed as Sunday to Saturday). I have a format value of d in each text
box.
The query uses a stored field which is the first of the month. That field
is called StartDate.
The query has a field called DayStart which is
"DayStart: Weekday([StartDate])"
This tells me the first day of the month (somewhere between 1 and 7) 1 being
Sunday and 7 Saturday. Looking at April 2007 where the fist was Sunday, the
value of this field is 1.
I have another field in the query called "L1" which is used as the
controlsource in the first text box. In the query
L1: IIf([DayStart]=1,[StartDate],"")
So if [DayStart] = 1 then L1 = First of the month - in my case 1st April.
The text box with the controlsource L1 has format of d to display only days.
I would expect to see "1" displayed. What I actually get is 1/4/2007
Just to confuse the situation, the second box (for Monday) has L2 for a
controlsource. L2 is
L2: IIf([DayStart]=2,[StartDate],IIf([DayStart]<2,DateAdd("d",1,[L1])))
Sooo if the weekday of 1 April were Monday it would display the start date
but since it isn't it displays L1 + 1 day. The text box has the same format
(d) and displays "2" which is what I want it to do. My question is why the
first date will now display as a day???????
that is a monthly calendar display - a box for each day. To determine which
day date to put in which box I find out the weekday of the first of the
month. If it is Sunday (weekday 1) I put "1" in the first box (Weeks are
displayed as Sunday to Saturday). I have a format value of d in each text
box.
The query uses a stored field which is the first of the month. That field
is called StartDate.
The query has a field called DayStart which is
"DayStart: Weekday([StartDate])"
This tells me the first day of the month (somewhere between 1 and 7) 1 being
Sunday and 7 Saturday. Looking at April 2007 where the fist was Sunday, the
value of this field is 1.
I have another field in the query called "L1" which is used as the
controlsource in the first text box. In the query
L1: IIf([DayStart]=1,[StartDate],"")
So if [DayStart] = 1 then L1 = First of the month - in my case 1st April.
The text box with the controlsource L1 has format of d to display only days.
I would expect to see "1" displayed. What I actually get is 1/4/2007
Just to confuse the situation, the second box (for Monday) has L2 for a
controlsource. L2 is
L2: IIf([DayStart]=2,[StartDate],IIf([DayStart]<2,DateAdd("d",1,[L1])))
Sooo if the weekday of 1 April were Monday it would display the start date
but since it isn't it displays L1 + 1 day. The text box has the same format
(d) and displays "2" which is what I want it to do. My question is why the
first date will now display as a day???????