Change background color of record

A

alex

Change background color of record

Using Access ’03…

I have a form set to continuous forms view. It’s based on a qry,
based on a tbl.

There are four controls, all bound to the query.

I understand that in continuous forms view, there’s really only one
control per field…I’m inquiring, however, if I can change the
background color of an individual record based on the value of a
control. Maybe continuous forms is not the way to go!

E.g.,
In the after update event of txtField1

Dim lngWhite as long
Dim lngRed as long
lngRed = RGB(255,0,0)
lngWhite = RGB(255,255,255)

If me.txtField1.value = “X” then
Me.txtField2.backcolor = lngRed
Else
Me.txtField2.backcolor = lngWhite
End if

In the code above, if txtField1.value is X, the backcolor of txtField2
will change to red for every record. I need only the individual
record (txtField2 in this example) to be red, not every occurrence
of.

Thanks for any advice.
alex
 
W

Wayne-I-M

Use condidtional formating for this. It will work fine for what you're
looking for.
 
A

alex

Use condidtional formating for this.  It will work fine for what you're
looking for.

--
Wayne
Manchester, England.














- Show quoted text -

Thanks Wayne for your help!
My example above should have been clearer. I'd like to set multiple
colors (red was just one example), around 8 of them. I believe that
CF will only allow for three.
alex
 
A

alex

Alex:

There's no way you'll be able to change the BackColor property in that way,
but one way you can have as many different 'colour codes' as desired is to
create a separate table with one column which holds distinct values of those
values in field 1 in the form's underlying table and another column with a
bitmap image, which in each case is a plain patch of the colour you wish to
associate with the value.

You can then base the form on a query which joins the existing table to the
'colours' table on field 1.  In the form include the bitmap image in a bound
control.  This can be as a colour 'patch' at the left or right end of the row,
or behind all the controls so it applies a colour background within in which
the controls sit, or behind one control so it shows as a coloured border
around the control.  Its really down to your imagination how you 'colour
code' each row in this way, and you can easily experiment by resizing and
repositioning the bitmap's control until you get a result which suits you..

Ken Sheridan
Stafford, England
Use condidtional formating for this.  It will work fine for what you're
looking for.
[quoted text clipped - 40 lines]
- Show quoted text -
Thanks Wayne for your help!
My example above should have been clearer.  I'd like to set multiple
colors (red was just one example), around 8 of them.  I believe that
CF will only allow for three.
alex

Very interesting Ken...Thanks.
I never thought of doing something like that.
Wayne was right too about the CF...I may have to limit it to three
colors.
alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top