Link to home
Start Free TrialLog in
Avatar of mtrussell
mtrussell

asked on

Add record to form on a tab folder

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.

Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

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
ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mtrussell
mtrussell

ASKER

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.  
Well, the code I posted shows how to identify the current 'Active' tab.

mx
Answer pointed me in right direction to complete.