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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change field color depending on value

Status
Not open for further replies.

sozzer

Technical User
Apr 4, 2005
73
0
0
GB
Hi all

I'm trying to build a project/ task management app for my own purposes and have the following problem:

I have a Status field on a form that changes it's value depending on whether a field named DueDate is showing a value in the past, in the future, or today (overdue, future dated, due today).

What i want to do is make this field change colour too, for each record. ie, so that overdue = red, future dated = blue etc).

If I use the forecolor property of the text box, all Status values in all records on the form are changed to the last record evaluated's color, presumably as im acting on the control and not the record.

I know this can be done, I just dont know how. If anyone has any ideas, id be very grateful.

cheers
 
If you have 2000 version, or higher, take a look at conditional formatting from the format menu.

Roy-Vidar
 
If you are using Access 2000 or above, look at Condidional Formating. That will do what you want.

Good Luck!

An investment in knowledge always pays the best dividends.
by Benjamin Franklin
Autonumber Description - FAQ702-5106
 
Yes, if you are using continuous forms, changing the color of a textbox will affect the same field for all records. Take a look at conditional formatting.

Ken S.
 
thanks, but the fields are locked so no can do. Also, forgot to clarify that the form is continuous. any ideas?
 
This I don't understand, you are able to change the forecolor of the fields (I suspect you mean form controls), but not use conditional formatting???

Conditional formatting should normally work on locked controls.

Roy-Vidar
 
Roy-Vidar

I do mean form controls rather than fields - sorry. the controls are also not enabled so conditional formatting is greyed out.

I can change the forecolor using vba on the form load event.

thanks in advance.
 
Sozzer,

So make the controls enabled. Through code you can make enabled fields look and act as if they were disabled. If you want to leave them locked but make them look like they are disabled, set the backcolor and forecolor properties accordingly. Then you can use conditional formatting.

Ken S.
 
Ok, i see what you mean, but i cant set the back color of a conditionally formatted control to -2147483633 so when you enter the enabled textbox the back color is white. I dont know how to make the control act exactly like it's disabled.

Also, I want to use this at my work too and they only have access 97.

Although this is only for my personal use, i am using this to try and learn more vba, so if possible want the final version to do exactly what i want it to.

cheers again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top