View Full Version : Tab Order in Forms with Multiple Subforms


Boraborasa
10-19-2000, 12:17 PM
First of all, Thanks everyone for taking the time to answer my question.
I have a form which consists of a main form and 3 subforms.
I can arrange the tab order for the main form in the Tab Order menu. However I can't arrange the tab orders for the subforms because the Text Box names are not listed in the Tab Order menu. Instead, I only see the names of the forms, such as frmAddNewProject, frmCostBreakdown and so on.

How can I arrange the tab orders for these subforms if I'm not able to see the "Text Box" names.

Thanks,
Bora

Travis
10-19-2000, 02:48 PM
You have to set the Sub Forms Controls tab order in the Sub Form. The Sub form on the Main form is a control that is why it shows up in the tab order.

Boraborasa
10-19-2000, 03:30 PM
Thanks for your replies Travis.
I figured that out with your help.
However, after you set the tab orders for the subforms how do you make the tab to go from 1st subform to the next subform?
For example; I set the tab order for the 1st subform. I can tab and go to the next text box in this subform which is fine. But, when I'm done with the last text box in this subfolder and press tab, it sends me back to the begining of this same subform rather than going to the first tab field in the next subfolder.
I hope you can tell me how to get around this.
Thanks again,
Bora

Keith P
10-19-2000, 05:02 PM
To tab out of a subform forward is ctrl+tab, backwards is ctrl+shift+tab. All very user friendly.

An alternative is to use the onExit event of the subforms last control to set the focus to another control. e.g.

me.parent![mycontrol].setfocus
or me.parent![my other subform].setfocus

Boraborasa
10-20-2000, 09:08 AM
Thanks a lot Keith.
Cntrl+Tab works great to move on to the next subform.

Your help is really appreciated.

Bora

[This message has been edited by Boraborasa (edited 10-20-2000).]

Lxocram
09-19-2008, 06:33 AM
If you do it with the on exit procedure (on last tab control)remember that users also use a mouse.
When focus is on the last control of the subform and user clicks another control (say a tabpage,or a button) the on exit event will still be triggered and focus will not be put on the control the user clicked.
The solution with a dummy control is a better one.
Also you can more easily shift or add controls to the form without breaking code, cause dummy remains last control in tab order

'EXAMPLE CODE FOR SINGLE RECORD FORM
'---------------------------
Private Sub LEAVESUBFORMDUMMY_GotFocus()
'When we enter subform next time whe don't want LEAVESUBFORM_GotFocus to get triggered
'As focussed control of a subform is remembered - so we set focus on first tab element of subform
Me.[First tab control].SetFocus
'Now whe do the actual Focus moving
Parent.SetFocus
Parent.subform2.SetFocus
Parent.subform2![First tab control of header].SetFocus
End Sub
'FROM FORM HEADER TO ACTUAL RECORDS
'----------------------------------
Private Sub LEAVEFORMHEADER_GotFocus()
Me![First tab control of record].SetFocus
End Sub
'FROM SUBFORM2 BACK TO PARENT
'----------------------------
Private Sub LEAVESUBFORM_GotFocus()
On Error GoTo Error_Routine
With Recordset
If .AbsolutePosition >= .RecordCount - 1 Then
Me![First tab control of header].SetFocus
Parent.SetFocus
Parent.[First tab control].SetFocus
End If
End With
Exit Sub
Error_Routine:
'Do error thingies e.g. Call LogError(...)
Exit Sub
End Sub