change textbox background color onchange of cbo

Gr3g0ry

Registered User.
Local time
Today, 15:19
Joined
Oct 12, 2017
Messages
163
Dim lngRed As Long, lngYellow As Long, lngWhite As Long

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

If Me.cboPartnerId.Column(16) = "" Or IsNull(Me.cboPartnerId.Column(16)) Then
Me.earlybtn.Enabled = True

Else
Me.earlybtn.Enabled = False
Me.ActualBalance.Value = owe
Me!DrawDate.BackColor = lngRed
Me!ActualBalance.BackColor = lngRed
End If

color wont change. am i even going about this thee right way ?
 
if you are not using Datasheet form, you can use Conditional Formatting.
add an Unbound Textbox on your form. Set its Visible Property to false:


now on your validation:
Me.UnboundTextbox = Me.cboPartnerId.Column(16) & ""

Me.earlybtn.Enabled = (Trim(Me.UnboundTExtbox & "")="")


back to your Conditional Format:


Expression: Trim([UnboundTextboxName] & "")=""


Chose what RED color on backcolor.



Expression:
 
im not using a datasheet form.
my textboxes Me!DrawDate & Me!ActualBalance are unbound textboxes.

not sure how to use what uve just told me
 
If Trim(Me.cboPartnerId.Column(16) & "")= "") Then
Me.earlybtn.Enabled = True
Me!DrawDate.BackColor = vbWhite
Me!ActualBalance.BackColor = vbWhite
Else
Me.earlybtn.Enabled = False
Me.ActualBalance.Value = owe
Me!DrawDate.BackColor = vbRed
Me!ActualBalance.BackColor = vbRed
End If
 
thanks. small correction tho, ur missing a parenthesis

If Trim((Me.cboPartnerId.Column(16) & "")= "") Then
Me.earlybtn.Enabled = True
Me!DrawDate.BackColor = vbWhite
Me!ActualBalance.BackColor = vbWhite
Else
Me.earlybtn.Enabled = False
Me.ActualBalance.Value = owe
Me!DrawDate.BackColor = vbRed
Me!ActualBalance.BackColor = vbRed
End If

did i mention that the textboxes are disabled ?? does that affect the color being changed ? i ask cause nothing has changed. if impossible to change the disabled textbox background color, how else can i make it stand out from all the other textboxes, enabled and disabled, on my form
 
yes it dies enable the control apply d color and diable them again
 

Users who are viewing this thread

Back
Top Bottom