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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lostfocus and exiting

Status
Not open for further replies.

influent

Programmer
Joined
Jan 11, 2001
Messages
131
Location
US
I have a form where a user enters an item number in a text box and the lostfocus event occurs when they tab out. If the user types a number in, hits tab, then hits a command button to go to another form, everything's fine. But when they go back to the original form, the number's still in the box (has to be that way) and so is the cursor (should be that way), so if the user clicks on "Exit", the lostfocus event occurs, ignoring the Exit_Click event. How can I make it so that they only have to click exit once? Is there a property like frmMain.TabIndex that returns the currently highlighted control?
 
To answer your question... you can use the ActiveControl property of the form to get the name of the control that has the focus.

me.ActiveControl.Name

What I would probably do, if I understand your problem correctly, is

In the LostFocus event of the textbox the first thing I would do is set the focus to another control on the form. then execute the rest of the code that you have in place.

just insert-> cmdExit.setfocus

This will prevent your textbox from have the focus when you return to the form.

Please let me know if this was helpful. cornerboyz@hotmail.com
 
????

If you will back return en set the focus on the control :in the command button on Form2 : Form1.Text1.Setfocus

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top