Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional formatting problem

Status
Not open for further replies.

hlkelly

Technical User
Jul 11, 2003
108
US
I have two controls [returndate] and [quickentry]

[quickentry] is a yes/no field. when selected yes, i'd like to highlight [returndate] yellow. i have placed conditional formatting on the returndate field which reads after selecting expression is [quickentry]="yes"

and then i've changed the formatting to background color yellow.

nothing happens when I changed the yes/no field. what am i doing wrong?

thanks.
 
Try something like this:

Private Sub quickentry_AfterUpdate()
returndate.BackColor = IIf(quickentry = -1, vbYellow, vbWhite)
End Sub

Regards,
gkprogrammer
 
I did something similar on a form. For the yes/no field, I used an event procedure for After Update. My yes/no field is named Check1 and the field I want to change the color is named Text1. The code is:

Private Sub Check1_AfterUpdate()

If Check1 Then
Me!Text1.BackColor = 8454143
Else
Me!Text1.BackColor = 16777215
End If

End Sub

This toggles the color of Text1 from white to yellow depending on the state of Check1.
 
bkprogrammer -

I get a compile error with that code. "method or data member not found and it highlights .backcolor =

diamondsc -

I get a run time error '438' and in debug

Me!ReturnDate.BackColor = 16777215

is highlighted. Suggestions?? Thanks!

 
returndate is a textbox control on your form correct?

If so all textboxes have a property called BackColor, I can't see how this could create an error if the above is true......

Regards,
gkprogrammer
 
I'm new...so bear with me. Thanks.

Yes. The field I'm trying to change is a text control from a table. The field is actually located in a subform but so is the check box. Both fields are from the same table.
 
Even more strange is when I actually force the backcolor for that field manually (within its own properties) it doesn't change at all on my form.
 
i should also mention that the subform is continuous... maybe that's the problem.
 
OK. I've tried code and conditional formatting.

Any other suggestions out there?
 
If the Form_Current event of the subform, try the following:

With Me.Controls("returndate").FormatConditions _
.Delete
End With

With Me.Controls("returndate").FormatConditions _
.Add(acExpression, acEqual, "UCase([quickentry])='YES'")
.ForeColor = .BackColor
End With

You also need to verify the actual value of [quickentry] is yes/no, because it might be True/False, or 1/0.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top