When tabbing out of a text box "txtWeight" on a main form "frmOrdersMain", I would like to have the focus set to combo box "ItemID" on a subform "frmOrderDetails".
I was thinking of putting the code as an "OnExit" event. Would that be right, and what would that code look like?
Any help is appreciated!
setting focus in a subform
-
- 3StarLounger
- Posts: 331
- Joined: 11 Feb 2010, 03:55
- Location: Land O Lakes, FL
Re: setting focus in a subform
If you only want to do this if you tab-out of txtWeight, I'd create a transparent command button, setting its tabIndex property to be the next control after txtWeight. Then in the OnEnter event of this new control, I'd have this code:
This assumes that the subform control name is frmOrderDetails.
Code: Select all
frmOrderDetails.setfocus
frmOrderDetails.form.ItemID
Mark Liquorman
Land O Lakes, FL
see my website http://www.liquorman.net for Access Tips and Tricks, and for my Liquorman Utilities.
Land O Lakes, FL
see my website http://www.liquorman.net for Access Tips and Tricks, and for my Liquorman Utilities.
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: setting focus in a subform
I think Mark forgot a SetFocus and meant to post
frmOrderDetails.SetFocus
frmOrderDetails.Form.ItemID.SetFocus
As Mark mentioned, you should use the name of the subform as a control on the main form. This is not necessarily the same as the name of the subform in the database window.
frmOrderDetails.SetFocus
frmOrderDetails.Form.ItemID.SetFocus
As Mark mentioned, you should use the name of the subform as a control on the main form. This is not necessarily the same as the name of the subform in the database window.
Best wishes,
Hans
Hans