Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lostfocus event fires regardless

Status
Not open for further replies.

Pipe2Path

Programmer
Aug 28, 2001
60
0
0

How do I prevent the lostfocus event from firing before
a click event fires?

I have a button that I use to SAVE information in a form. There is another text box in this form that has code in it's lostfocus event. When I click on the SAVE button, instead of running the code behind that button, the lostfocus event fires first. I need to stop that. I can't seem to run the SAVE code before the lostfocus code. Frustrating....

Any help would be appreciated.

 
The textbox will fire it's Lostfocus before the CmdButton gets focus. Tell us a bit more about what you're trying to achieve as there may be another way to do it.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Ok, the SAVE button calls a validation routine when clicked.
The text box also calls the same validation routine when its lostfocus event is fired. If I have the user clicking on the SAVE button, I don't want to run the lostfocus event of the text box. Is this possible?
 
Just a thought: Is there any event that I could run before the lostfocus event is fired to tell that the SAVE button was pressed?
 
Pipe2Path,

You say that the same validation routine is called with both objects, why not just call it on the SAVE button and
address the textbox validation code there...


If textbox <> vbnull then
......validate textbox code
end if

the other way you could use a boolean flag and trigger
it on or off when the textbox "gotfocus"

 
You can also place the validation code in the textbox validate event only. This is fired after the lost focus event. This event allows you to cancel (set the cancel parameter to true) and return focus to the textbox if the entry is not valid. In other words the user must enter valid data in order to move on. Then there is no need to check the data again in the button click event, just to save the data.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top