Color Footer Textboxes at Weekend Dates

D

Datalore

Hi all, hope all goes well.

I have a series of Text Boxes in a group Footer of a Report, from D1 to D31,
representings days of a month.

For the Month of August, say, I would like to change the BackColor of the
text boxes to light grey (gray?), where the Day is either Sat/Sun.

I am trying to do this in a loop - On the report, in the footer section, I
am right-clicking and selecting Build Event:

' eom is calculated to be the last day of a month - the month supplied from
a query as a parameter

For i = 1 to eom ' for August this will be 31

'pseudocode:

If Day(i & "/" & [QueryMonth] & "/2005")= Sat OR Sun Then
Me.("D"&i).BackColor = colorNo ' a number representing the
colour grey

Next i

Hope you giuys can help!
 
D

Dennis

Not sure if your statement to set the back colour will work but your if needs
to be like this

If Weekday(i & "/" & [QueryMonth] &"/2005") = 1 Or Weekday(i & "/" &
[QueryMonth] & "/2005") = 7 Then
 
M

Marshall Barton

Datalore said:
I have a series of Text Boxes in a group Footer of a Report, from D1 to D31,
representings days of a month.

For the Month of August, say, I would like to change the BackColor of the
text boxes to light grey (gray?), where the Day is either Sat/Sun.

I am trying to do this in a loop - On the report, in the footer section, I
am right-clicking and selecting Build Event:

' eom is calculated to be the last day of a month - the month supplied from
a query as a parameter

For i = 1 to eom ' for August this will be 31
'pseudocode:
If Day(i & "/" & [QueryMonth] & "/2005")= Sat OR Sun Then
Me.("D"&i).BackColor = colorNo ' a number representing the
colour grey
Next i


To avoid being dependent on the machine's regional settings,
you should use the DateSerial function:

intY = 2005
For i = 1 to DateSerial(intY, QueryMonth + 1, 0)
If WeekDay(DateSerial(intY, QueryMonth, i), 2) > 5 Then
Me("D" & i).BackColor = RGB(224,224,224)
Next i

I don't feel comfortable using a hard coded year like that.
Try to figure a way to eliminate that, even if it's just
something simple like:
intY = Year(Date)
 
Top