Control back color problem

D

Dave

I have four controls on a report the first called: One, Second, Third and Fourth. This is how they are supposed to work

One needs to diplay a back color of Green if the value is >= 94% and Orange if the value is < 94

Second needs to diplay a back color of Green if the value is >= 97% and Orange if the value is < 97

Third needs to diplay a back color of Green if the value is >= 80% and Orange if the value is < 80

Fouth needs to diplay a back color of Green if the value is >= 75% and Orange if the value is < 75

However, the only control that seems to change colors is One, the others do not. Any ideas why that may be

The code sits in the "Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)". Should this change

Below is the sample code as it is is now

If Me![txtFirst].Value >= 95% The
Me![txtFirst].BackColor = 425958
Me![txtFirst].ForeColor = vbWhit
Me![txtFirst].FontBold = Tru
ElseIf Me![txtFirst].Value < 95% The
Me![txtFirst].BackColor = 422732
Me![txtFirst].ForeColor = vbGree
Me![txtFirst].FontBold = True
End I

If Me![txtSecond].Value > "97.0%" The
Me![txtSecond].BackColor = vbGreen '425958
Me![txtSecond].ForeColor = vbBlu
Me![txtSecond].FontBold = Tru
ElseIf Me![txtSecond].Value < "97.0%" The
Me![txtSecond].BackColor = vbYellow '422732
End I

If Me![txtThird].Value >= 80% The
Me![txtThird].BackColor = 425958
ElseIf Me![txtThird].Value < 80% The
Me![txtThird].BackColor = 422732
End I

If Me![txtFourth].Value >= 75% The
Me![txtFourth].BackColor = 425958
ElseIf Me![txtFourth].Value < 75% The
Me![txtFourth].BackColor = 422732
End I

Any ideas or code corrections will be appreciated.

Thanks,...
 
D

Duane Hookom

I would get rid of the quotes in the txtSecond code. Also, try use .95
rather than 95%. Your code assumes your controls are in the GroupFooter1
section.

--
Duane Hookom
MS Access MVP
--

Dave said:
I have four controls on a report the first called: One, Second, Third and
Fourth. This is how they are supposed to work:
One needs to diplay a back color of Green if the value is >= 94% and Orange if the value is < 94%

Second needs to diplay a back color of Green if the value is >= 97% and Orange if the value is < 97%

Third needs to diplay a back color of Green if the value is >= 80% and Orange if the value is < 80%

Fouth needs to diplay a back color of Green if the value is >= 75% and Orange if the value is < 75%

However, the only control that seems to change colors is One, the others
do not. Any ideas why that may be?
The code sits in the "Private Sub GroupFooter1_Format(Cancel As Integer,
FormatCount As Integer)". Should this change?
Below is the sample code as it is is now!

If Me![txtFirst].Value >= 95% Then
Me![txtFirst].BackColor = 4259584
Me![txtFirst].ForeColor = vbWhite
Me![txtFirst].FontBold = True
ElseIf Me![txtFirst].Value < 95% Then
Me![txtFirst].BackColor = 4227327
Me![txtFirst].ForeColor = vbGreen
Me![txtFirst].FontBold = True
End If

If Me![txtSecond].Value > "97.0%" Then
Me![txtSecond].BackColor = vbGreen '4259584
Me![txtSecond].ForeColor = vbBlue
Me![txtSecond].FontBold = True
ElseIf Me![txtSecond].Value < "97.0%" Then
Me![txtSecond].BackColor = vbYellow '4227327
End If

If Me![txtThird].Value >= 80% Then
Me![txtThird].BackColor = 4259584
ElseIf Me![txtThird].Value < 80% Then
Me![txtThird].BackColor = 4227327
End If

If Me![txtFourth].Value >= 75% Then
Me![txtFourth].BackColor = 4259584
ElseIf Me![txtFourth].Value < 75% Then
Me![txtFourth].BackColor = 4227327
End If

Any ideas or code corrections will be appreciated.

Thanks,...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top