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.
6 1661
To change the memo field's back color - Private Sub fcmFLAG_AfterUpdate()
-
Select Case fcmFLAG
-
Case "Problem"
-
fcmFcom.BackColor = vbRed
-
Case "Call"
-
fcmFcom.BackColor = vbGreen
-
Case "Hold Off"
-
fcmFcom.BackColor = vbBlue
-
Case "Withdrawn"
-
fcmFcom.BackColor = vbYellow
-
Case "Ineligible"
-
fcmFcom.BackColor = vbCyan
-
Case Else
-
fcmFcom.BackColor = vbWhite
-
End Select
-
End Sub
-
So that the color formatting is maintained moving record to record - Private Sub Form_Current()
-
Select Case fcmFLAG
-
Case "Problem"
-
fcmFcom.BackColor = vbRed
-
Case "Call"
-
fcmFcom.BackColor = vbGreen
-
Case "Hold Off"
-
fcmFcom.BackColor = vbBlue
-
Case "Withdrawn"
-
fcmFcom.BackColor = vbYellow
-
Case "Ineligible"
-
fcmFcom.BackColor = vbCyan
-
Case Else
-
fcmFcom.BackColor = vbWhite
-
End Select
-
End Sub
-
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)> NeoPa 32,584
Recognized Expert Moderator MVP
Don't listen to him. He's no good. - Try Private Sub fcmFLAG_AfterUpdate()
-
Call setColour()
-
End Sub
-
-
Private Sub Form_Current()
-
Call setColour()
-
End Sub
-
-
Private Sub SetColour()
-
Select Case fcmFLAG
-
Case "Problem"
-
fcmFcom.BackColor = vbRed
-
Case "Call"
-
fcmFcom.BackColor = vbGreen
-
Case "Hold Off"
-
fcmFcom.BackColor = vbBlue
-
Case "Withdrawn"
-
fcmFcom.BackColor = vbYellow
-
Case "Ineligible"
-
fcmFcom.BackColor = vbCyan
-
Case Else
-
fcmFcom.BackColor = vbWhite
-
End Select
-
End Sub
Of course I nicked all the actual code from Linq :D
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
NeoPa 32,584
Recognized Expert Moderator MVP
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 : - Clearly the same.
- 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.
Fess up, NeoPa! You're just trying to sow confusion in a newbie so they'll have to come back!
Linq ;0)> NeoPa 32,584
Recognized Expert Moderator MVP
IT'S ALL TRUE!! <crying with shame>
I confess :(
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 marked
as deleted. I understand the conditional formatting is available in
Access 2000 for this purpose, but it is not in 97. Is there a way to
emulate this effect through code? Thanks for any input on this
matter.
Alan
|
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 beginning with B)
B E
C D (One color for the combo beginning with C)
|
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 background
colour.
In A2000 it works great, but in A2003 the background doesn't always
change and when it does it only changes when the record looses the
focus.
Any way around this? Is it a bug? Or have they "improved" it?
|
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 main form has personal info on it. The
subform deals with each case's Issues, Decisions, and Notices.
Issues, Decisions, and Notices are all combo boxes. Not all Issues
have Notices. Issues 25-50 have Notices. Issues 1-24 and 51-100 don't
have...
|
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 create a Yes/No field in a
Table the default format is "Yes/No". If I clear or change the Format
property in the General Tab (and keep the default "Checkbox" in the Lookup
tab), the field still looks the same when I open the table in Datasheet...
| |
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 access database.
|
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
perfectly. However, I have code that runs under the ON CLICK event. The
code changes the focus to other controls, which means the conditional
formatting is no longer displayed. This part makes sense to me.
Here's what doesn't make sense. The last...
|
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 textbox
background to display yellow, else I want it to be just white. Here's
my code... but it is not working
Private Sub Form_Load()
If Me!STATUS = "Inactive" Then
Me!STATUS.BackColor = RGB(255, 255, 0)
Else
|
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 called Person. It is looking up the category type from another table called WorkCategory which is a list of 3 types of categories (offshore, onshore, visitor).
In the form, when I use the drop-down menu of the combo box to select one of the work...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |