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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatconditions problem

Status
Not open for further replies.

yourdeployedson

Programmer
Feb 8, 2006
11
US
Below is my code. It works when I select option 1 or option two it changes my format conditions without a problem. However, I have to manually open the format conditions from the menu bar and click ok for it to actually take affect. I cant seem to make it active automatically. Can anyone help me?



Private Sub cmdChange_Click()

Dim objFrc As FormatCondition
Dim lngRed As Long
Dim lngWhite As Long
Dim lngBlack As Long
Dim lngYellow As Long

lngRed = RGB(255, 0, 0)
lngWhite = RGB(255, 255, 255)
lngBlack = RGB(0, 0, 0)
lngYellow = RGB(255, 255, 0)

Me![txtResult].FormatConditions.Delete

Set objFrc = Me![txtResult].FormatConditions.Add(acFieldValue, acEqual, "LNE")
Set objFrc = Me![txtResult].FormatConditions.Add(acFieldValue, acEqual, "CQ")
Set objFrc = Me![txtResult].FormatConditions.Add(acFieldValue, acEqual, "Day Off")

Select Case cmdChange.Value

Case 1

With Me![txtResult].FormatConditions(0)
.BackColor = lngwhite
End With

With Me![txtResult].FormatConditions(1)
.BackColor = lngblack
End With

With Me![txtResult].FormatConditions(2)
.BackColor = lngyellow
End With

Case 2

Set objFrc = Me![txtResult].FormatConditions.Add(acFieldValue, acEqual, "DFAC")
Set objFrc = Me![txtResult].FormatConditions.Add(acFieldValue, acEqual, "Day Off")
Set objFrc = Me![txtResult].FormatConditions.Add(acFieldValue, acEqual, "CQ")

With Me![txtResult].FormatConditions(0)
.BackColor = lngRed
End With

With Me![txtResult].FormatConditions(1)
.BackColor = lngBlack
End With

With Me![txtResult].FormatConditions(2)
.BackColor = lngYellow
End With

End Select

End Sub

 
yourdeployedson,

Why do you use RGB instead of VB color constants

vbRed
vbWhite
vbBlack
vbYellow

vladk
 
And BackColor... It doesn't look like valid property here. Even the long variables are not capitalized meaning a problem. Look for Interior, Border, and Font properties.

vladk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top