Conditional formatting

M

maceslin

The following code to change the color of the text is working

Private Sub cboClassification_AfterUpdate()
Select Case cboClassification.Value
Case 6
cboClassification.ForeColor = vbRed
Case 7
cboClassification.ForeColor = vbRed
Case 8
cboClassification.ForeColor = vbGreen
Case Else
cboClassification.ForeColor = vbBlack
End Select
End Sub

but

when I move to the next record and open cboClassification all entries
in the drop down are the color from what was last selected. How do I
get cboClassification drop downs to revert to black when I enter into
a new record while at the same time keep old records as slected?

hope this makes sense
Dave
 
M

maceslin

define them as black at the beginning of your code module
--
NTC







- Show quoted text -

inserted
cboClassification.FontColor= vbBlack

before Select Case statement with no change
 
M

maceslin

inserted
cboClassification.FontColor= vbBlack

before Select Case statement with no change- Hide quoted text -

- Show quoted text -

make that ForeColor not FontColor
 
L

Linq Adams via AccessMonster.com

For the formatting to persist, i.e. if RecordA has a cboClassification value
of 6, for it to always be colored Red when you return to it, the
cboClassification has to be bound to a field in your underlying table, and
you need to place your code in the Form_Current event as well as in the
AfterUpdate event of the cbo. After doing this, since the cboClassification
value will be Null when first moving to a new record, the Null value falls
under the Case Else, and the forecolor will be Black until you make a
selection from the cbo.

Private Sub Form_Current()

Select Case cboClassification.Value
Case 6
cboClassification.ForeColor = vbRed
Case 7
cboClassification.ForeColor = vbRed
Case 8
cboClassification.ForeColor = vbGreen
Case Else
cboClassification.ForeColor = vbBlack
End Select

End Sub
 

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