I have a form with a text box, an ok button and a cancel button on. When I exit the text box I perform some validation and either stay on the text box or populate some other fields and exit.
This works fine if I put the code in the textbox's 'Leave' event or 'validating' event. The problem is if the user enters invalid information I display an error message and stay on the same field. I can close the form by pressing the 'X' button but I cannot close the form by pressing my 'Cancel' button as the textbox's event is processed first.
Is there any way I can determine in my validation routine which button caused the 'validating' event to be fired. i.e. which field will next receive the focus.
What I want to do is not perform the validation is the 'Cancel' button is pressed.
This works fine if I put the code in the textbox's 'Leave' event or 'validating' event. The problem is if the user enters invalid information I display an error message and stay on the same field. I can close the form by pressing the 'X' button but I cannot close the form by pressing my 'Cancel' button as the textbox's event is processed first.
Is there any way I can determine in my validation routine which button caused the 'validating' event to be fired. i.e. which field will next receive the focus.
What I want to do is not perform the validation is the 'Cancel' button is pressed.