Changing text color in vba (1 Viewer)

JPFred

Registered User.
Local time
Yesterday, 20:23
Joined
Oct 29, 2017
Messages
47
This is more than likely a simple question.


I have a for that loads a record from a table and displays the record for editing.


What I would like to happen is to change the background and/or text in a combo box if the data coming in meets a given condition, I.E.


Code:
Private Sub Form_Load()

Dim background As String

background = "#ED1C24"

If Me.comcondition.Value = "5 - Poor" Then
    comcondition.BackColor = background
End If

End Sub


I hope this details my question / idea.


Doc
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:23
Joined
Feb 19, 2013
Messages
16,607
put your code in the current event rather than the open event. the recordset doesn't get loaded until the load event and the current record is not selected until the current event

alternative to vba code is to use conditional formatting
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 20:23
Joined
May 21, 2018
Messages
8,527
if this form is continuous you have to go with conditional formatting. Easier either way.
 

Users who are viewing this thread

Top Bottom