Solved

Add record to form on a tab folder

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

Industry Leaders: 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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

685 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