Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add record to form on a tab folder

Posted on 2011-03-22
5
Medium Priority
?
191 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 1500 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

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…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

636 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