Change Fore Color

Eddie Mason

Registered User.
Local time
Today, 21:45
Joined
Jan 31, 2003
Messages
142
I have set certain fields to have a red “Fore Color” to indicate to the user that these fields need updating. After the field has been updating I change its “Fore Color” from red to black to do this I have put the following code onto the fields “On Change Event”:

Private Sub SKU_Change()
Me!SKU.ForeColor = vbBlack
End Sub

This works fine until the form is closed. When it is re-opened it has not saved the changed “Fore Color” and has reverted back to red.

Can anyone help me make the change permanent.

Kindest regards

Eddie
 
You need some code in the 'On Current' event of the form to test which fields need updating.


Something like:

Code:
If me.fldNumber < 10 then
    me.fldNumber.forecolor = vbRed
else  
    me.fldNumber.forecolor = vbBlack
endif

Otherwise the forecolor will be what you specified in the design properties.

Catalina
 
Hi Catalina,

I am assuming that from your advice I will need to create a blind field with a default value of 0 for each of the fields that needs to be amended, and as each field is amended on its update event its corresponding blind field value is changed to 1.

Is that what you are suggesting?

Kind regards,

Eddie Mason
 
No that is not the case.

You just have to test the values of the existing fields to see if they meet the criteria. Like a number has has to be between certain values, or text that has to be of a certain length, or a field that cannot be left empty
If a field does not meet the criteria you can show a message, set the cursor
back to the field or in your case, change the forecolor.

Catalina
 
Hi Catalina,

Sorry for the delay coming back but had the opportunity to get away for a few days; I have now managed to get the colour change working.

Many thanks for your help it was appreciated.

Kind regards,

Eddie
 

Users who are viewing this thread

Back
Top Bottom