Detect Textbox Change by User but not by Software code

Hello,
I know you can use _LostFocus and _Change methods to detect when a text box has changed. In my case, if a certain situation exists, I want to pop-up a message to the user. The problem is if I put that pop-up in _LostFocus or _Change it happens too much at random times as that value may be "changed" by software code.

How do I detect that the user really tried to change the value? But EXCLUDE all cases where the value is changed by code?

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Don't try to move in different event, it's _Change you need to code.
But there a public variable "codechange As Boolean" and in textbox_Change this line:
If codechange Then Exit Sub

Need to set this variable true just before you program executes code which will change text in that textbox, and set it false again when the changes are made.

Matti

torrid333Author Commented: 2006-04-19

The trick is really to do something a combo of cubixSoftware and Matti's suggestions...

I used a boolean in KeyPress to indicate that text is "dirty"... that the user has actually tried to change the value... and then in LostFocus it is checking that dirty flag to determine whether to pop up the user message. That flag is then cleared after showing the message.

cubix... if you just put the message in KeyPress then it will try to pop up the message every time they hit a key. This leads to too many pop-ups.

Matti... the code changes this value in lots of places... very inconvenient to set that boolean everywhere in code. Plus, a year from now it may be forgotten and then voila new bug appears adding new unneeded msg pop-ups.