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

Changing focus from one textbox to the other 2

Status
Not open for further replies.

ugagrad

Programmer
Sep 12, 2003
49
US
I have a form with four textboxes on it (A,B,C, and D). I am trying to use the value of Textbox D to determine which of the other textboxes will receive focus. I have the following code in the keypress event for box D.

IF nKEYCODE = 13 &&ACSII for the enter key
mX = ALLTRIM(str(thisform.textD.value))
IF !ISBLANK(thisform.textD.value)
mControl = 'thisform.txt'+mX+'.SetFocus()'
&mControl
ENDIF
ENDIF

the problem I am having is if the user enters 'A' in box D the focus is set to 'A' and then focus goes to the next box in the tab order. So basically it goes to the box I want it to and then tabs from there.

Thanks in advance
 
the problem I am having is if the user enters 'A' in box D the focus is set to 'A' and then focus goes to the next box in the tab order. So basically it goes to the box I want it to and then tabs from there.

After you set focus to the desired control, you need to add a NODEFAULT. However, I think this code belongs in the LostFocus() and not the KeyPress.



Marcia G. Akins
 
Make sure you have a NODEFAULT in your LOSTFOCUS() method, so the normal tab order isn't followed. You may need to set a property in KEYPRESS() that you can check in LOSTFOCUS().

Rick
 
Marcia,
Unfair, you just type faster than I do! :)

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top