MS Access Change Textbox Background Color Depending on Another Textbox Value On a Continuous Form

Dustin Stanley
Dustin Stanley used Ask the Experts™
on
I have a subform for notes. In this subform it has a combo box for choosing Private or Public. I would like to have my notes background to change color depending upon if the notes are Private or Public for easy distinction between the two types.

My only issue is how do I make the continuous form have different background colors for each record while they are all showing in a continuous form display?

Something like:
If Me!txtPrivatePublicID.Value = "1" Then
   Me!txtSourceSkuNote.BackColor = vbYellow
 End If
    
  If Me!txtPrivatePublicID.Value = "2" Then
     Me!txtSourceSkuNote.BackColor = vbBlue
  End If

Open in new window


 If Forms!frmSKuSource!frmSourceSkuNotes.Form!txtPrivatePublicID.Value = "1" Then
   Forms!frmSKuSource!frmSourceSkuNotes.Form!txtSourceSkuNote.BackColor = vbYellow
 End If
    
  If Forms!frmSKuSource!frmSourceSkuNotes.Form!txtPrivatePublicID.Value = "2" Then
     Forms!frmSKuSource!frmSourceSkuNotes.Form!txtSourceSkuNote.BackColor = vbBlue
  End If

Open in new window


Thanks for the help!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Remote Training and Programming
Top Expert 2015
Commented:
hi Dustin,

you can use conditional formatting

1.  in the design view, select the textbox you want to change color
2.  click Conditional Formatting on the Format ribbon tab
3. click New Rule
4. choose Expression Is
5.  enter the expression ... ie: [MyOtherFieldname] = 2
6. then choose the formatting you want and click OK

have an awesome day,
crystal
Dustin StanleyEntrepreneur

Author

Commented:
PERFECT! THANKS!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial