By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,444 Members | 3,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,444 IT Pros & Developers. It's quick & easy.

Conditional formatting, changing a memo contingent on a combo

P: 26
Hi all
Iím trying to figure this out. But help is needed. I have a combo box called fcmFLAG with 5 options (problem, hold off, call, withdrew and ineligible). What I would like to do is have the background in a memo box (fcmFcom) change to a different color for each option. I donít think this can be done with Conditional formatting because itís more then 3. The problem is that I just started getting into VBA but I have been using Access for over a year. So any help with coding this would be of great help.
Oct 23 '07 #1
Share this Question
Share on Google+
6 Replies


missinglinq
Expert 2.5K+
P: 3,532
To change the memo field's back color

Expand|Select|Wrap|Line Numbers
  1. Private Sub fcmFLAG_AfterUpdate()
  2.   Select Case fcmFLAG
  3.     Case "Problem"
  4.       fcmFcom.BackColor = vbRed
  5.     Case "Call"
  6.       fcmFcom.BackColor = vbGreen
  7.     Case "Hold Off"
  8.       fcmFcom.BackColor = vbBlue
  9.     Case "Withdrawn"
  10.       fcmFcom.BackColor = vbYellow
  11.     Case "Ineligible"
  12.       fcmFcom.BackColor = vbCyan
  13.     Case Else
  14.       fcmFcom.BackColor = vbWhite
  15.    End Select
  16. End Sub
  17.  
So that the color formatting is maintained moving record to record

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Select Case fcmFLAG
  3.     Case "Problem"
  4.       fcmFcom.BackColor = vbRed
  5.     Case "Call"
  6.       fcmFcom.BackColor = vbGreen
  7.     Case "Hold Off"
  8.       fcmFcom.BackColor = vbBlue
  9.     Case "Withdrawn"
  10.       fcmFcom.BackColor = vbYellow
  11.     Case "Ineligible"
  12.       fcmFcom.BackColor = vbCyan
  13.     Case Else
  14.       fcmFcom.BackColor = vbWhite
  15.    End Select
  16. End Sub
  17.  
Of course, the combo box has to have it's value bound to a field in the table for the formatting to hold.

Welcome to TheScripts!

Linq ;0)>
Oct 24 '07 #2

NeoPa
Expert Mod 15k+
P: 31,494
Don't listen to him. He's no good.
Expand|Select|Wrap|Line Numbers
  1. Try Private Sub fcmFLAG_AfterUpdate()
  2.   Call setColour()
  3. End Sub
  4.  
  5. Private Sub Form_Current()
  6.   Call setColour()
  7. End Sub
  8.  
  9. Private Sub SetColour()
  10.   Select Case fcmFLAG
  11.     Case "Problem"
  12.       fcmFcom.BackColor = vbRed
  13.     Case "Call"
  14.       fcmFcom.BackColor = vbGreen
  15.     Case "Hold Off"
  16.       fcmFcom.BackColor = vbBlue
  17.     Case "Withdrawn"
  18.       fcmFcom.BackColor = vbYellow
  19.     Case "Ineligible"
  20.       fcmFcom.BackColor = vbCyan
  21.     Case Else
  22.       fcmFcom.BackColor = vbWhite
  23.    End Select
  24. End Sub
Of course I nicked all the actual code from Linq :D
Oct 24 '07 #3

P: 26
You guys rock, this worked like a charm. On a side note, since I'm just getting started with VBA can you recommend any good sources to study (websites, books tutorials).
Thanks
Steve
Oct 24 '07 #4

NeoPa
Expert Mod 15k+
P: 31,494
It's all Linq's work really of course. I just added the format of how to reuse code in multiple events so that it's :
  1. Clearly the same.
  2. Maintainable in a single place.
I can give you a link to an index of our Articles section (Full List of Articles and Code in this Section). This may not have what you're looking for but I'm afraid I don't have any links to learning tutorials.
Oct 25 '07 #5

missinglinq
Expert 2.5K+
P: 3,532
Fess up, NeoPa! You're just trying to sow confusion in a newbie so they'll have to come back!

Linq ;0)>
Oct 25 '07 #6

NeoPa
Expert Mod 15k+
P: 31,494
IT'S ALL TRUE!! <crying with shame>
I confess :(
Oct 26 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.