Click to See Complete Forum and Search --> : validating text boxes


simonsjd
October 12th, 2001, 09:17 AM
Hi
I'm trying to validate data in a text box using the lost_focus event. This works except for the text box that has the focus when the form is closed. The lost focus event does not seem to run then. Can anyone tell me the best method for validating text boxes.

Thanks
Simon Dennis

DSJ
October 12th, 2001, 09:47 AM
You might take a look at the validate event (also the causesvalidation property).

Iouri
October 12th, 2001, 01:37 PM
Write your validation procedure not in the lost focus event, but separately. On the lost focus event call this procedure as well as on form unload event. If on the form unload event validation did not pass through, do not unload the form.

Iouri Boutchkine
iouri@hotsheet.com

SAKYA
October 14th, 2001, 07:07 AM
When you click on a control(like a command button ao a text box), the control takes focus before the click event is executed there by firing the lostfocus event of the previous control and the gotfocus event of the current control.But it is an exception with the form.Even when you are closing the form the text box keeps the focus and hence the lostfocus event is not fired.So follow Louri's advice and use a separete procedure and call it in lostfocus event of the textbox as well as in the unload event of the form.

simonsjd
October 15th, 2001, 09:11 AM
Thanks everyone - problem solved