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

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!
LVL 1
Dustin StanleyEntrepreneurAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dustin StanleyEntrepreneurAuthor Commented:
PERFECT! THANKS!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.