Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional formatting using VBA in Access

Status
Not open for further replies.

JPimp

Technical User
Mar 27, 2007
79
0
0
US
I set up a reference table in Access 2000 with some specs, now I want to reference this table and color code my form based on the value, for example.

I want to check to see if tablename.fieldname is less than or equal to field1 or greater than or equal to field1, and then color = red, yellow or green.

I looked online and I have done something like this using Select case statements in VB.NET, but never referencing a table and field name


Kai-What?
 
create a table

[tt]StartValue, EndValue, ColorValue
1, 100, 100
101, 199,200
201 ,299,300
...




[/tt]

in the record souree of the form join the item table on item price between startvalue and endvalue


on form current
me.Detail.BackColor = ColorValue
 
Why not simply use conditional formatting in your form ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV:

Can conditional formatting be used on form? Ithink only on text and combo boxes.
 
I did use conditional formatting on the form to begin with, but the problem is if I wanted to color code based on value and product code, and we wanted 1 stop-shop to make changes to the reference table instead of adjusting the code inside the form's conditional formatting code.



Kai-What?
 
In VBA you may play with the FormatConditions collection of each relevant controls.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top