Synch Probleme, lostFocus and Unload Event

Sandro Cella
04-07-2003, 11:20 AM
This is my probleme,

On my form, i have a textbox that i check if the value with in is Valide, if not, a msgbox pops is displayed and the Focus is Set on the textbox.

On the Unload event, i display a new form for the user to enter a final value necessary for the application.

When a invalid value is inserted into the textbox, and the users clicks on the small 'x' to close the window, both events are triggered which causes an error when i try got give the focus to the textbox.

Any tips on fixing this?

BankCop
04-07-2003, 08:15 PM
This is my probleme,

On my form, i have a textbox that i check if the value with in is Valide, if not, a msgbox pops is displayed and the Focus is Set on the textbox.

On the Unload event, i display a new form for the user to enter a final value necessary for the application.

When a invalid value is inserted into the textbox, and the users clicks on the small 'x' to close the window, both events are triggered which causes an error when i try got give the focus to the textbox.

Any tips on fixing this?

In the Form_QueryUnload event, if the UnloadMode is vbFormControlMenu, call the Textbox Validate event and cancel the unload.

Sandro Cella
04-08-2003, 06:09 AM
A little more help plz :), actually, i am not using a textbox, its a DrowDown combo Box and i am not using the validate event. Maybe i should?, i was using the lost focus event to check the data if its valide.

Gonna try using the validate Event

Sandro Cella
04-08-2003, 06:21 AM
Validate works great, i'm a bit scared of using this since it says that u have to use this in tandem with other controle that have causevalidation set to true. Since i`m not sure all the controls on the form have this on, i can predict how the app is gonna work for now.

But i had one more question, how do you call an event? (edit: that was a stupid question :P, found answer just trying stuff :P)

How from the queryUnload event can i know that the data is valide or not? i would need to know if the data is valide, then i can launch the unload event, if not, cancel it.

Thx

BankCop
04-08-2003, 11:00 AM
Validate works great, i'm a bit scared of using this since it says that u have to use this in tandem with other controle that have causevalidation set to true. Since i`m not sure all the controls on the form have this on, i can predict how the app is gonna work for now.

But i had one more question, how do you call an event? (edit: that was a stupid question :P, found answer just trying stuff :P)

How from the queryUnload event can i know that the data is valide or not? i would need to know if the data is valide, then i can launch the unload event, if not, cancel it.

Thx

In the QueryUnload event, if the unload mode is vbFormControl, indicating that the X button was pressed, just call the Validate event for the control(s) you want to validate

Call Combo1_Validate

etc.

Actually, I usually write a separate subroutine to validate all the data on the form at one time when the user presses a command button to Save or whatever. I've found that users generally don't like to hear about their errors until they're completely done with data entry. Just a suggestion.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum