Tabbing Subforms

Ian Mac

MrExcel MVP
Joined
Feb 20, 2002
Messages
1,174
All,

Can anyone point me in the direction of how to Tab between subforms in the normal fashion, inc, Shift+Tab.....

I have 13 Subforms on my Main form,
The problem is that each one is set to Cycle Current Record so I as soon as I tab into the Subform it tabs round and round.

I have tried using OnExit on the last control in each form:

e.g.

[Forms]![Subform2].Setfocus

But this doesn't really tackle the problem.

Would really like this to be sorted as it's a big part of the user interface.

Cheers.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi,

isn't it ctl + tab ?

Or,you could create your own method if you think that your interface would benefit. Using the Form KeyDown event, you could trap pgUp & pgDn (or what ever keys you think best) and move between the subforms...

Merry Xmas!

stubby
 
Upvote 0
Cheers Stubby but the interface would definately benefit.

Anyways I've solved the issue very neatly, and if anyones interested:

I created a tiny tranparent button on each of the subforms with it set as the last Tab Stop.

Then I've used the on Enter event:

Private Sub Cb_Enter()

If Screen.PreviousControl.Name = "Date" Then
On Error Resume Next
Me.Parent.cmbBack.SetFocus
Else
On Error Resume Next
Me.Parent.cmbForward.SetFocus
End If

End Sub

Then on the main Form I have 2 more transparent buttons, these don't need Tab Stops

cmbBack and cmbForward

The code on these 2 is similar to:

Private Sub cmbForward_Enter()

Dim forward As String

If IsNull(Screen.PreviousControl.Name) Then
Else
forward = Screen.PreviousControl.Name

Select Case forward

Case "frm_1_Subform"

Me!frm_2_Subform.SetFocus
Me!frm_2_Subform.Form!Date.SetFocus

Case "frm_2_Subform"

Me!frm_3_Subform.SetFocus
Me!frm_3_Subform.Form!Date.SetFocus

Case "frm_3_Subform"

Me!frm_4_Subform.SetFocus
Me!frm_4_Subform.Form!Date.SetFocus

Case Else

End Select

End If
End Sub

And the reverse for the other one.

Works like a charm, and makes my smile :)

Happy Christmas

Cheers,
 
Upvote 0

Forum statistics

Threads
1,221,838
Messages
6,162,286
Members
451,759
Latest member
damav78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top