472,146 Members | 1,212 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

Suppress focus events of a textbox control in Validating event

Hello

I have a Data Entry Form having some controls including a TextBox. When the
user types an entry, I query a table and if it was entered before, I ask the
user (using ShowModal method of a custom message form) if he wants to see
his old entry in a new form. if he/she choose Yes, I create a new form and
show the previously entered data in it.

The problem is when I create and show the new form, the validating event is
fired two times and so it asks again if the user wants to see previously
entered data.
The application is an MDI application.

Please help me what am I wrong with.
Regards
Hamed
Jun 9 '07 #1
3 1864

"Hamed" <ha***@raymehr.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hello

I have a Data Entry Form having some controls including a TextBox. When
the user types an entry, I query a table and if it was entered before, I
ask the user (using ShowModal method of a custom message form) if he wants
to see his old entry in a new form. if he/she choose Yes, I create a new
form and show the previously entered data in it.

The problem is when I create and show the new form, the is fired two times
and so it asks again if the user wants to see previously entered data.
The application is an MDI application.

Please help me what am I wrong with.
Why don't you pass a local scope Boolean flag in the form's constructor, and
at the validating event check the flag, if the Boolean flag is true bypass
code/exit or else execute the code and exit?

Jun 9 '07 #2
The Validating event of the first form is fired twice not the second form.

I think there is some interference between focus events and ShowModal
method.

Please help. Am I wrong in using the Validating routines?

Hamed

Why don't you pass a local scope Boolean flag in the form's constructor,
and at the validating event check the flag, if the Boolean flag is true
bypass code/exit or else execute the code and exit?

Jun 9 '07 #3

"Hamed" <ha***@raymehr.comwrote in message
news:O$**************@TK2MSFTNGP02.phx.gbl...
The Validating event of the first form is fired twice not the second form.
Well, you should still be able to set some kind of flag there too. Maybe
some flag in a Global scope.

It's the same thing with having Textbox_Change event firer on a Form_load
where you have code in the TextBox_Change event, and you only want the code
in the event to executed when the user changes data in the Textbox.

You don't want the Textbox_Change event to firer on the Form_Load and
execute code because you populated default data in the TextBox.Text =
"MM/DD/YYYY", as an example for display purpose, which will make the
Textbox_Change event firer and code executed if you do bypass it during the
Form_Load.

You simply avoid the situation by setting a gbBoolen flag to true to make it
bypass the code in the Event and set it to false at the end of the Form_Load
to make the event execute the code when it's fired due to the user changing
data in the TextBox.

It's the same principles here. You know the conditions as to when this is
happening so set a Global Boolean flag, if you must, to true and bypass
code execution and set it to false when the method is exited.
Jun 9 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Patrick De Ridder | last post: by
1 post views Thread by seash | last post: by
reply views Thread by Miquel | last post: by
10 posts views Thread by Dennis | last post: by
2 posts views Thread by Jonathan N. Little | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.