Tab/Enter key focus moved to wrong control (1 Viewer)

Elvis

Registered User.
Local time
Today, 11:11
Joined
Sep 28, 2001
Messages
26
I have a number of textbox controls which have the KeyPress event coded to:

If AsciiKey = 13 then <control>.setfocus

from a combo box if tab is pressed things work fine. If however, the enter key is pressed on the Combobox the focus moves to the correct control but seems to have an AsciiKey of 13 this immediately passes the focus to the next control. If I remove the KeyPress code for the textbox the focus remains in the right control, but I cant then use the enter key and have to tab.

Any ideas how i can keep the enter key option and get the focus to stay in the first textbox.
 

KDg

Registered User.
Local time
Today, 11:11
Joined
Oct 28, 1999
Messages
181
hi,

as you say the enter key is now being processed twice - first due to you code and then due to its regular method. You'll need to cancel the regular method if you want to stop it moving twice

eg

if keyascii=13 then
lalala.setfocus
keyacii=0 ' changes the value being passed to the 'regular event' to a non-existent value, in effect cancelling it.
end if

hope that's what you're after - and welcome to the forum! i had no idea The King was chilling out in watford these days, got any new stuff coming out for us?

[This message has been edited by KDg (edited 09-28-2001).]
 

Elvis

Registered User.
Local time
Today, 11:11
Joined
Sep 28, 2001
Messages
26
Thanks KDg, I will give that a go, and thanks for the welcome. I have only just discovered this site, seems great.
 

Users who are viewing this thread

Top Bottom