Pierre,
I'm not exactly sure I understand what you are trying to do.
I get the part that you have three textboxes that you want to color code
based on some "Classification" value. If you "classification", you mean
"Unclassified", "Confidential", "Secret", ... I do this type of thing all
the time. The question is, do you have a field that has this value in it,
or do you have multiple fields?
If all you have is one field that contains this value, then you could put
some code in the forms Current Event, and in the AfterUpdate event of the
control where you select this value. As an example, I have a combo box on a
form where I select one of the three values shown above. The combo box is
based on a table that contains numeric values of 1, 2, 3 for the three
classification values above. I also have two textboxes (one at the very top
and one at the very bottom of the form, both of them locked) where I want to
display these values and change the background color when the value in the
combo box changes. So, I might write a subroutine that updates the color
and the text in each of these textboxes.
Private Sub ColorClassification
'set the text of each of the textboxes
me.txt_Class1.Value = me.cbo_Classification.column(1)
me.txt_Class2.Value = me.cbo_Classification.Column(1)
Select Case me.cbo_Classification
Case 1
me.txt_Class1.Backcolor = 255
me.txt_Class2.Backcolor = 255
Case 2
me.txt_Class1.Backcolor = 12345
me.txt_Class2.Backcolor = 12345
Case 3
me.txt_Class1.Backcolor = 32455
me.txt_Class2.Backcolor = 32455
Case else
me.txt_Class1.Backcolor = 3333
me.txt_Class2.Backcolor = 3333
End Select
End Sub
Then, I would put code in the combo boxes AfterUpdate event, and the forms
Current event that calls this subroutine. You need to call this code in the
AfterUpdate event so that it changes the color coding whenever the user sets
the value in the combo box. You need to call this code from the Forms
Current event to ensure that when you go to another record, that it color
codes the tab properly.
Private Sub cbo_Classification_AfterUpdate
Call ColorClassification
end sub
Private Sub Form_Current
Call ColorClassification
end sub
HTH
Dale
Pierre said:
The code that you gave me worked. But I have a small issue making it work
with another field and new record.
More info on what my intent is. I have a classification banner above my
form and below it. The Classification box is the same for the exception
of
the fact that I would only use one as an entry field. -I have not disable
the lower text field yet - On top of that, the banner is also on 2 other
tab
pages. So of course the field name [Classification] changes to
[text171],[text172]......
I have used the same code and placed it in the On Enter property field.
This only updates on the other tabs [field(s)] once I click in the field.
And when I change records, the backcolor does not change or display the
color
with the corresponding text already entered. If the multiple text fields
does not allow this to work as I intend, is it possible to use a Macro to
accomplish this. Any suggestion would be helpful.
--
Work is sometimes hard....but someone has to do it.
:
How about something like:
Private sub txt_YourControlName_AfterUpdate
if instr(me.txt_YourControlName, "SAM") = 1 then
me.txt_YourControlName.Backcolor = 255
elseif instr(me.txt_YourControlName, "TALL SAM") = 1 then
me.txt_YourControlName.Backcolor = 65535
else
me.txt_YourControlName.Backcolor = 16777215 'white
End if
End Sub
--
Don''t forget to rate the post if it was helpful!
email address is invalid
Please reply to newsgroup only.
:
I have a field on a form that I would like for the back color to change
based
on a word entered. (2x deferent words/colors)
ex. when the word "SAM" is entered, the back color change to red (255)
when the word "TALL SAM" is entered, the back color change to
yellow
(65535)
Additional info: "SAM" will be entered in something like this..
SAM//FYI,FYO -or-
SAM//AKA,BKA
and "TALL SAM" will be entered like...
TALL SAM//FLA,CA -or-
TALL SAM//TEX,NYC
so I'm thinking *SAM*=([back color]=255) will not work since TALL SAM
has to
be a different color.
FORMULA IS JUST AN EXAMPLE - I know its not right
Work is sometimes hard....but someone has to do it.