SetFocus on a Sub-Form w/ a Tab Control Box

G

Guest

I'm having difficulty setting focus on a Sub-Form containing Tabs after
clicking a button on the main form. Here's a detailed description.

My Main Form has 8 Tabs. On Tab #7, I have a button labeled "View". (The
button is right next to a text field - pressing the button takes you to the
sub-form where that value came from).

When pressing the button on Tab #8, I want the form to bounce to Tab #3. On
Tab #3, I have a subform... and on that subform I have another Tab Control
Box. That Tab Control Box on the sub-form has 4 tabs. I need to go to Tab
#4 of that TabControl Box. Is there a way to do this? I tried multiple
combinations of the SetFocus and am having no luck.

To summarize, when pressing the button on Tab #7 of the main form, I want my
form to bounce to Tab #3 of the main form >>> and then go to Tab #4 of the
sub-form found on Tab #3. Is that possible? And if you wanted to, can you
go to a specific field on that sub-form?

The TabControl Box Name for the Main Form is "TabCtl0" and the TabControl
Box Name for the Sub-Form on Tab #3 is "TabCtl1".

Me.TabCtl0.Value = 2 ... takes me to the right tab on my main form. but I
now need to go to Tab #4 on the sub-form contained in this tab.

Any help is greatly appreciated.

Thanks so much.

Frank
 
K

Ken Snell [MVP]

You'll need a few code steps in sequence to do what you seek:

' Set focus on the subform control (Note: SubformControlName
' is the name of the control that holds the subform)
Me.SubformControlName.SetFocus
' Make tab 4 visible in the subform
Me.SubformControlName.Form.TabCtl1.Value = 2
 
G

Guest

Ken, that worked like a charm. Thanks. Great way to start the day. Ken,
can I now set focus to a specific field on the form? My code now reads...

Private Sub Command473_Click()
' Set focus on the subform control (Note: SubformControlName
' is the name of the control that holds the subform)
Me.Child317.SetFocus
' Make tab 4 visible in the subform
Me.Child317.Form.TabCtl1.Value = 3
End Sub

The field is called [Accepted Offer Amount]. Would I just add another line
right before closing out the routine?

Frank
 
E

Ed Robichaud

Not elegant, but 2-3 sendkey macros will accomplish what you want. Are you
sure about this form/navigation design? Eight tabs and subforms with more
tabs! It sounds awfully busy. It's not always best to try to show every
thing in one place. Think of the better designed, more intuitive programs
that you admire. They tend to show a info summary, but provide drill down
capability and/or popup forms form more detail.
-Ed
 
K

Ken Snell [MVP]

Sure... just one more step:

Private Sub Command473_Click()
' Set focus on the subform control (Note: SubformControlName
' is the name of the control that holds the subform)
Me.Child317.SetFocus
' Make tab 4 visible in the subform
Me.Child317.Form.TabCtl1.Value = 3
' Set focus on the desired control in the subform
Me.Child317.Form!NameOfControlInSubform.SetFocus
End Sub


Note that, if you want to set focus to a control in the subform, you can
eliminate the step to set the tab control's value:

Private Sub Command473_Click()
' Set focus on the subform control (Note: SubformControlName
' is the name of the control that holds the subform)
Me.Child317.SetFocus
' Set focus on the desired control in the subform
Me.Child317.Form!NameOfControlInSubform.SetFocus
End Sub


--

Ken Snell
<MS ACCESS MVP>

Frank said:
Ken, that worked like a charm. Thanks. Great way to start the day. Ken,
can I now set focus to a specific field on the form? My code now reads...

Private Sub Command473_Click()
' Set focus on the subform control (Note: SubformControlName
' is the name of the control that holds the subform)
Me.Child317.SetFocus
' Make tab 4 visible in the subform
Me.Child317.Form.TabCtl1.Value = 3
End Sub

The field is called [Accepted Offer Amount]. Would I just add another
line
right before closing out the routine?

Frank

Ken Snell said:
You'll need a few code steps in sequence to do what you seek:

' Set focus on the subform control (Note: SubformControlName
' is the name of the control that holds the subform)
Me.SubformControlName.SetFocus
' Make tab 4 visible in the subform
Me.SubformControlName.Form.TabCtl1.Value = 2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top