Form to subform cursor placement

JIMR

JIMR
Local time
Today, 02:14
Joined
Sep 26, 2008
Messages
63
MS XP
MS Access 2003

I have a form with a subform (is a Datasheet) when I move from the last entry on the main form by press entry or tab it moves to the subform as needed. I have the tab order setup correctly so the first contol I want contains the cursor and every thing works fine.

However, if on any preceding record I click a field whether i enter data or not the next movement from the main form goes to the field I clicked and the tab order is ignored.

I have tried a couple of setfocus statements such as when the subform gets the focus that the focus be set to the correct field but none of them work.

Any suggestions? Your help is appreciated
 
this is a little bit vague. can you upload jpegs to illustrate?
 
Setting the focus to a control on a SubForm is a two step process.
Me.SubFormControl.SetFocus
Me.SubFormControl.FORM.ControlName.SetFocus
 
The subform remembers the last field that had focus in it.
When you tab into the subform, it will automatically return the focus to the last field in the subform to have had the focus, rather than the 1st control of the subform. (or last, if you were shift-tabbing.)

If you want to be able to tab into a subform from either direction transparently (as if it were not a subform, but part of your parent form) you will need to capture the TAB key, cancel the event, and set the focus on the 1st (or last) control manually in VBA.

Use the Key Down event of the control before the subform.

If KeyCode = 8 and Shift = 0 then 'Tab = 8 Shift = 1
KeyCode = 0 'Cancels the Tab Key Event
MYsfrm.Setfocus
MYsfrm.Form.Control1.SetFocus
end if

Use the same code in the Key Down event of the control following the subform to allow Shift-Tabbing into the last control of the subform - expect Shift = 1 (instead of 0)

Evan
 
Setting the focus to a control on a SubForm is a two step process.
Me.SubFormControl.SetFocus
Me.SubFormControl.FORM.ControlName.SetFocus

RG & ajetrumpet, this worked like a charm thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom