473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Conditional formatting, changing a memo contingent on a combo

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
6 1632
missinglinq
3,532 Expert 2GB
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
32,556 Expert Mod 16PB
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
BUmed
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
32,556 Expert Mod 16PB
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
3,532 Expert 2GB
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
32,556 Expert Mod 16PB
IT'S ALL TRUE!! <crying with shame>
I confess :(
Oct 26 '07 #7

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

Similar topics

3
by: Andante.in.Blue | last post by:
Hello everyone! I'm building a form in Access 97 and I want to to show a special icon if the record has been marked as deleted. Obviously, I don't want the icon to show if the record was not...
2
by: jeffgeorge | last post by:
Trying to add 3 colors to 6 combinations of text possibilities. If this makes sense, the possibilities are: A D (one color for the combo beginning with A) A E B D (One color for the combo...
4
by: Bradley | last post by:
I have an A2000 database in which I have a continuous form with a tick box. There is also a text box with a conditional format that is based on the expression , if it's true then change the...
2
by: Megan | last post by:
Can you write conditional VBA code that affects only one or two records on a continuous subform? I have a form with a subform on it. The parent/ child field that links the forms is CaseID. The...
4
by: deko | last post by:
I've heard it's best not to have any formatting specified for Table fields (except perhaps Currency), and instead set the formatting in the Form or Report. But what about Yes/No fields? When I...
12
by: dmieluk | last post by:
Problem: When moving between records, I need to control which combo/text boxes are displayed on the current form, dependent upon data in the current record. More: I building my first...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
4
by: slinky | last post by:
Thanks in advance... I have a continuous style form with a field for each record called "STATUS". I simply want to have the form load and if the value of the textbox is "Inactive" I want the...
3
by: aeon | last post by:
Working in Access 2007 on XP I have a combo box that I'm using in a form to select the WorkCategory assigned to a particular person in my database. WorkCategory is a lookup field in a table...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.