coloring a combobox selection, permamentally.

Punice

Registered User.
Local time
Today, 04:15
Joined
May 10, 2010
Messages
135
(Access 2007) I have a combobox (Classifier) that displays the selected phrase from the list and colors the Classifier field appropriately when I use this sub-routine, 'On-Change'. (On-Current didn't work for me.)


1. The colorization is not retained, when the form is closed & reopened, only the selected phrase is.

2. The background color of the 'Classifier' field is retained, if the form is not saved or is closed and I advance to open a new form, using the bottom arrows,

3. What vba do I need to include to do that? I'm Asking for help, again, because the due date for completion my project is approaching.

Private Sub Classifier_lbl_Change()
If Me.Classifier_lbl.Text = "CAN use this broker." Then
Me.Classifier_lbl.BackColor = vbGreen
Me.Classifier_lbl.ForeColor = vbBlack
ElseIf Me.Classifier_lbl.Text = "Slow paying broker." Then
Me.Classifier_lbl.BackColor = vbYellow
Me.Classifier_lbl.ForeColor = vbBlack
ElseIf Me.Classifier_lbl.Text = "Do NOT use this broker." Then
Me.Classifier_lbl.BackColor = vbRed
Me.Classifier_lbl.ForeColor = vbBlack
Else
Me.Classifier_lbl.BackColor = vbWhite
Me.Classifier_lbl.ForeColor = vbBlack
End If
'remind the user to save the form when any field is altered or filled
FormHeader.BackColor = vbYellow
End Sub

 
Last edited:
Sounds like you're looking for the Current event.
 
The colorization is retained when the form is closed & reopened, only the selected phrase is. But, the background color of the 'Classifier' field is retained, if the form is not saved or closed and I advance to open a new form, using the bottom arrows, What vba do I need to include to do that? I'm Asking for help, again, because the due date for completion my project is approaching.

Try to read the above text again. I suspect there are some "no" or "not" missing here and there, because the text makes no sense. Fix the text and post again.
 
Why did the current event not work? You don't need the .Text property, which will error if the control doesn't have focus.
 
Thank you Spikepl for discovering the omissions in my initial post.
Thank you Pbaldy for solving my problem. I removed the 'text' as
you suggested. When I added the SR to On-Current, I had to keep
the SR in the combobox as well. Now, the colors are retained when
I exit & reenter a form and not conveyed to a new form that I open.
That's why you get the big buck... you know this Access stuff.
 

Users who are viewing this thread

Back
Top Bottom