Solved

Add record to form on a tab folder

Posted on 2011-03-22
5
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

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