Solved

Add record to form on a tab folder

Posted on 2011-03-22
5
185 Views
Last Modified: 2012-05-11
I have a form that has a tab control with three different tabs.  Each tab has it's own subform added to each tab.  I have a button to add record but I can't figure out in VBA how identify which tab is active then add a record to the subform that is active.  Any help would be appreciated.  I am using Access 2007.

0
Comment
Question by:mtrussell
  • 2
  • 2
5 Comments
 
LVL 75
ID: 35192122
How about this:

Private Sub Command2_Click()
    Dim x
    For x = 0 To Me.TabCtl1.Pages.Count - 1
        If Me.TabCtl1 = x Then MsgBox "active tab is " & x & "  " & Me.TabCtl1.Pages(x).Name
    Next x
End Sub

mx
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 35192144
I assume you are using unbound forms otherwise the Q would not arise.

The value of a tab control indicates which tab is active.

x= me.tabcontrolname
if x= 0 then
'first page
elseif x= 1
'second tab
else
'third tab
end if
0
 

Author Comment

by:mtrussell
ID: 35192603
I think I wasn't very clear on this example.

I have an unbound form and it has a tab control.  On the unbound form it says add new record.  I need to identify the tab which is open and then ADD a record to the form which is active.  There are technically three subforms on this form and add a record needs to add it to the appropriate subform.  
0
 
LVL 75
ID: 35192682
Well, the code I posted shows how to identify the current 'Active' tab.

mx
0
 

Author Closing Comment

by:mtrussell
ID: 35426544
Answer pointed me in right direction to complete.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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