tab automatically goes two fields ahead

pauly

Registered User.
Local time
Today, 20:36
Joined
Jul 8, 2002
Messages
49
Hi
i am having a problem with using tab. I have subforms inside a main form and to get back to the main form text fields i have used in the KeyDown event of the last text field:
if KeyCode = 9 Then '9 meaning tab
Forms!main!Text2.SetFocus
end if.
but when this occurs instead of stoping at Text2 it goes through Text2 and straight to Text3, which is the next tab index after Text2. Why isnt it stopping at Text2, there is no code in Text2 to move the focus to Text3, just the next Tab Index.
Thanks
 
Because (I think) you are setting the focus correctly - but the tab keydown event still has to be processed. This moves the focus on to the next control, which is the one following the control you put the focus upon. To stop this put a line in your code:

KeyCode = 0

which will 'kill' the tab keypress.
 

Users who are viewing this thread

Back
Top Bottom