Solved

Add record to form on a tab folder

Posted on 2011-03-22
5
180 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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 …

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now