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

Curious problem with Conditional Formatting...

Status
Not open for further replies.

missinglinq

Programmer
Feb 9, 2002
1,914
US
I've got a single view form with text boxes. I just set the Conditional Format for all text boxes so that when the field has focus, the background/foreground colors of the field change.

I have code in the Form_Dirty sub that makes visible two command buttons to save or cancel changes that have been made.

The "curious problem" is that when some of the fields get focus, the Form_Dirty event is being triggered!

Any ideas?

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Form had apparently become corrupted! I imported the most recent copy of it (before the Conditional Formatting) from my backup copy and did the Conditional Formatting thing again and it works fine now! Score a point for backing up frequently!

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Disregard my second post. I hadn't done the Conditional Formatting on all of the fields yet, and the one I tested on the imported form was not done yet! So the problem still exists. Conditional Formatting appears to be making the form "Dirty." Should have had my coffee first!

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Try testing the conditional formatting (change). Does that ALONE cause Dirty to be set? If So, add a routine to check wheather .OldValue = .Value of the controls. Id So, you might just set dirty = false. Of coursem it would need to be done with care, as you appear to be interested in (using) "dirty", so preserving it for real changes also needs to be considered. Altogether seems like a high price to pay if conditional formatting is the culprit.



MichaelRed


 
If you want to change the color when the textbox gets focus, why not use the Textbox_GotFocus event instead of the Form_Dirty event. I believe the Form_Dirty event will only fire when data on the form has changed from it's original state. So simply clicking into a field will not trigger the Form_Dirty event.
 
I was already using the GotFocus and LostFocus events on all the text boxes, so I did just that, rjoubert!

Thanks to you and MichaelRed for your help!

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Sorry, I misread your original post. Apparently, I need some coffee!

Michael's reply sounds like it would work. I would setup a form level variable (boolean) and add the check for .OldValue = .Value to the LostFocus of each control. If they're not equal, set the boolean to True. Then, in your Form_Dirty event, check the value of your boolean, and if it's true, show your buttons.
 
How are ya missinglinq . . .

Just a thought . . . instead of making the buttons visible, default them to disabled and enable them in the [blue]Dirty[/blue] event . . . maybe this will make the difference . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top