View Full Version : Problem with if


Sharon Hague
10-28-2003, 08:34 AM
Hi All

I have a problem with some coding I have entered into a report I have created.

My report comprises of 3 fields - MyDate, MyDay and Overtime.

I want the report to show Saturdays in red, therefore I have entered the following code into the on format part of my detail part of my report: -

If Me.MyDay = 7 Then
Me.MyDay.FontBold = True
Me.MyDay.ForeColor = vbRed
Else
Me.MyDay.FontBold = False
Me.MyDay.ForeColor = vbBlack
End If

When I run the report everything is displayed in black.

What am I doing wrong?

I'd appreciate anybody's help on this.

llkhoutx
10-28-2003, 10:20 AM
Try placing you code in the report's OnFormat event.

Pat Hartman
10-28-2003, 11:22 AM
That's the onFormat event of the Detail Section.

Sharon Hague
10-29-2003, 04:05 AM
llkhoutx & Pat

Thanks for you reply, however this is where I have enter my code which is why I don't understand why it is not working.

Any ideas?

Rich
10-29-2003, 05:47 AM
What is MyDay displaying, 7 or Saturday?

llkhoutx
10-29-2003, 06:50 AM
Run thrtough your code with the Debugger on. I;m often surprised that my code isn't doing what I think it's doing.

Sharon Hague
10-30-2003, 01:31 AM
Rich

MyDay is displaying Sat as its format is ddd.

I have tried changing 7 to "Sat" in my code but it still doesn't like it.

Any ideas?

Rich
10-30-2003, 05:25 AM
If (WeekDay(Me.MyDate) = 7) Then
Me.MyDay.FontBold = True
Me.MyDay.ForeColor = vbRed
Else
Me.MyDay.FontBold = False
Me.MyDay.ForeColor = vbBlack
End If

Sharon Hague
10-31-2003, 01:01 AM
Rich

Thanks that's worked a treat.