?
Solved

Have Tab Control on Subform move to first Tab Control from outside the subform

Posted on 2006-04-27
3
Medium Priority
?
273 Views
Last Modified: 2008-03-17
I have a form called Main.  On this form I have a subform called Sub1.  On Sub1 I have 4 Tab pages.

On the main form I have a button that adds a new record.  What I want to do is when I push the add record button on the Main form, the sub1 form Tab page will move to the first page if it is not already on the first page.  Then I want the focus to go to a field on the main form.  This is the coding in the button:

   
DoCmd.GoToRecord , , acNewRec
Me.Invoice_TO.SetFocus


0
Comment
Question by:Shaft960
3 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 1000 total points
ID: 16559733
You can do that by first moving the focus to a control on the first tab followed by the SetFocus on the mainform.

DoCmd.GoToRecord , , acNewRec
Me.subformname.form.FieldOnFirstTab.SetFocus
Me.Invoice_TO.SetFocus

Nic;o)
0
 
LVL 16

Expert Comment

by:GreymanMSC
ID: 16559737
'<!-- Substitute the names of your controls where needed -->

Private Sub TheAddNewButtonName_Click()
  '<!-- goto the new record / or use your own code -->
  DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
  '<!-- Set the Value of the Tab Control -->
  If Not Me.Sub1.Form!TheTabControlName.Value = 0 Then
    Me.Sub1.Form!TheTabControlName.Value = 0
  End If
  '<!-- Set the focus to the field you want -->
  Me.TheFieldName.SetFocus
End Sub
0
 

Author Comment

by:Shaft960
ID: 16559761
Thank you it worked.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question