Tab Order in Forms with Multiple Subforms

  • Thread starter Thread starter Boraborasa
  • Start date Start date
B

Boraborasa

Guest
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
 
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.
 
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
 
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
 
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).]
 
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
 
I am indeed getting an error (Return without go Sub) with the 'On Exit' procedure when I use my mouse to try and click on a control earlier in the same sub form. For reference, I used the code below.

Private Sub OA_2019_Exit(Cancel As Integer)
Me.Parent![SbFrm2020 LEVELS (ALL)].SetFocus
End Sub

I tried entering your code on my own, but I got confused with where to put each code, and what control to put where.
I just need a little more help to use the dummy code you pasted above. First, I'm guessing the text in ' ' are not part of the code, just the explanation?
second, as far as I can see, you have 3 sub commands;

1. Private Sub LEAVESUBFORMDUMMY_GotFocus()
2. Private Sub LEAVEFORMHEADER_GotFocus()
3. Private Sub LEAVESUBFORM_GotFocus()

Do all 3 of these go in the same code (control) window, or do they get entered in different VBA locations?
Also, I wasn't sure what you meant by [First tab control of Header] (all my subforms are in the 'Detail' portion of the form)

Thank you so SO much for any help you can give me! It's really really appreciated!
 

Users who are viewing this thread

Back
Top Bottom