Click here to Skip to main content
15,895,525 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All,

How Can I Check If A Cmd Button Was Pressed At LostFocus Time?

I have a form that, if the cancel button is pressed before anything is entered, it performs the LostFocus processing for the first field.

If the first field is blank, an error is displayed.
I need to be able to tell if the Cancel command button was pressed and, if so, bypass the edit on the LostFocus.

How can I do this?

Thanks in advanced!
Rahul Chitte :)
Posted
Updated 16-Nov-10 21:47pm
v2
Comments
Dalek Dave 17-Nov-10 3:47am    
Edited for Readability.

1 solution

Hey I got answer,

In VB6 there is one property named ActiveControl which tell us which control is currently active, So i wrote following code in textbox_LostFocus event to resolve my issue :

If (Me.ActiveControl.Name) = cmdCancel.Name Then
Unload Me
Exit Sub
End If
 
Share this answer
 
Comments
gaurav ghodnadikar 17-Jan-11 8:51am    
Thanks rahul,
This is really helpful post....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900