colors for fonts

mhtmarsha

Registered User.
Local time
Today, 01:05
Joined
Jan 4, 2002
Messages
19
I have a form that I want the text to change colors when a certain condition is met. such as:
form_current
footlights.forecolor = Iff(footlights.text = "xx/xx", 0, 235)

I have several of these fields and can't seem to get it to allow me to do this. I would like the colors in the fields because it brings attention to those fields when the form pops up. I don't know alot of code so i could be in the wrong place with the wrong code?
 
In the Form Current event you need to reference the controls as they relate to their containing object (the form) using the Me keyword (which refers to the current object). Also I am not sure if the value you are using for the colour is correct. I generally use the colour picker that is launched from the property sheet. Once I have picked a colour, the full number representing the colour that you want is displayed in the property sheet and you can copy it.
So I would put this in Form_Current

If me.footlights = "xx/xx" then
me.footlights.forecolor = 16744448
else
me.footlights.forecolor = 0
end if

P.S. You probably want to add the same code to the AfterUpdate of the footlights control. In this way the fore color will update each time the control's value is changed.
HTH
Chris
 
I tried the code above and couldn't get it to work. So I tried my code in the exit event and it worked. It turned the field red upon exiting the field if the condition was right but I need it not to change unless someone puts in something different. Also when i went to the next record it kept the the red color in the field until I exited that field. Is there a way to prevent that? Is there another place I can put this code?
 
Hey mhtmarsha,

Try putting your code in the Forms On Active property also and see if that doesn't cure your problem.

HTH
Shane
 
Put the code in the After Update event of the control whose value will define the colour change. You can add whatever logic you need to define if or when the colour changes happens.

The code needs to be in ON Current of the form as well.If you do not get the code working there, then navigating to new records will not trigger the colour change.

If you still can not get it to work, then set a breakpoint at the beginning of the On Current code and see why the code does not execute properly...
Chris
 
Put the code in the After Update event of the control whose value will define the colour change. You can add whatever logic you need to define if or when the colour changes happens.

The code needs to be in ON Current of the form as well.If you do not get the code working there, then navigating to new records will not trigger the colour change.

If you still can not get it to work, then set a breakpoint at the beginning of the On Current code and see why the code does not execute properly...
Chris
 
I put the code in OpenForm and AfterUpdate and the code likes it there so well it travels to the next record. If I change the next record and go back to the previous record it changes that record also. There must be a way to keep it in one spot. I tried the breakpoint but came up empty. Anyone's help is greatly appreciated.
 
Are we talking about a continuous form and which version of Access?
 
Access version 2000 and the form is a form for my main parent table. The informaion in this form is used in several other tables but this form will be used by users and needs to have some field stick out more than others but only when the information in those fields has certain data. I know I sound off but the table this information was in before we had access had these features and I could control all aspects of the information including how it was presented to the user. I fairly new to access and I longing for the same freedom with this program. Maybe I am to new with the program and don't know the right questions to ask.
 
One improvement in A2k (perhaps the only)is the inclusion of conditional formatting, look it up in the help file, presumeably it contains examples.
 
THANK YOU THANK YOU SO MUCH! I just knew i wasn't asking the right questions. All this time something so simple. Where have you been all my life. Once again thank you!
 

Users who are viewing this thread

Back
Top Bottom