Need help: Tabbing from Main Form to Sub Form

  • Thread starter Thread starter ZRexRider
  • Start date Start date
Z

ZRexRider

I have a form that contains:
3 fields associated with a master table,
a search button and
a sub-form for entering related child data.

When you tab through the form it allows you to enter the 3 master data
fields and sets focus to the Search button. If you tab once more it
writes the master record data and starts a new master.

I would rather tab order go from the button to the first field of the
sub-form. Any tips on coding this will be appreciated. It's probably
easy (since it seems normal) but I'm not finding the answer.

Thanks
 
Hi

Sounds like you need to rejig the Tab Order. (in Form Design, View
menu, Tab Order). Put the subform control into the right place,
immediately following the last of your 3 data fields. You may need to
rejig the subform's control Tab Order as well (I think Tab Order is set
by default according to the order in which you create controls).

Getting the focus to come back "out" of the subform and go onto the
Search button is more difficult, since as you've found, on a particular
form the Tab order is always circular - once you reach the end of the
Tab Order, tabbing further just takes you back to the start of the
order, on the next record.

One way I've done this is to trap the TAB key in the last control's
KeyDown event. (It has to be the KeyDown - by the time the TAB key
"bounces back up" and triggers the KeyUp event, focus will have moved
already to the next control). You can set focus back to the main form
in this event. If I remember rightly you also have to set the keycode
to 0, otherwise Access also "receives" the TAB press and tries to do
something with it - i.e. moving focus to somewhere where you don't want
it to be.

cheers


Seb
 
Interesting - I didn't know that. So you should be able to force the
last control on the subform to react to TAB (with no shift, i.e. Shift
argument is 0) by giving focus back to the main form, by setting the
Shift argument in the KeyDown event to the CTRL constant acCtrlMask.

Seb
 
Back
Top