Solved

What event triggers when using Tab Control in MS Access

Posted on 2013-10-22
8
841 Views
Last Modified: 2013-10-22
I am not sure if there is an answer for this.  I am using a tab control on an Access form.  I want to trigger code to run when someone clicks on a new tab.  There is an "On Click" event for the page but that will only trigger if someone triggers "in" the page, not the tab on top.  Because I need to reset the page before it is viewed, this doesn't work for me,  They will see stale data.  Any ideas?
0
Comment
Question by:marku24
[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
8 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 39591575
Try the change event of the tab control itself (not the pages).

This for example will return the page index as the user switches tabs:

Private Sub TabCtl4_Change()
MsgBox Me.TabCtl4
End Sub

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39591577
try the "on change" event of the tab control
0
 

Author Comment

by:marku24
ID: 39591625
This is helpful but two questions from here; 1) how do I then reference the particular page's index?  Something like

 If Form_Menu.TabDashboard.index = 1 then "do this"

2) do I have to use index to reference the page?  Can I get page name?  I may change the order of my pages while developing which would change my index.

Thanks
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 61

Accepted Solution

by:
mbizup earned 305 total points
ID: 39591644
This is a common approach:

SELECT case Form_Menu.TabDashboard
          Case 0
                ' do something

          Case 1
                  ' do something
          Case 2
                  ' do something

End select

Open in new window



... and if the order of the pages is changed during development, just change the numbers in the case statements accordingly.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39591654
Or if you must use the name:

me.TabDashboard.Pages(Me.TabDashboard).Name


(I prefer using the simpler syntax)
0
 

Author Closing Comment

by:marku24
ID: 39591693
very helpful.  thanks
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39591934
I prefer to use the Caption property

me.TabDashboard.Pages(Me.TabDashboard).Caption property, since this is far easier to read and understand when debugging code.  

It is kind of like referring to rs!Fieldname instead of rs(0).  If you don't know what the fields are or what sequence they are in, then rs(0) can get you in trouble.
0
 

Author Comment

by:marku24
ID: 39592044
Thank you Fyed.  I agree and built the case statement off of the page names.  Thanks all...
0

Featured Post

Independent Software Vendors: 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

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

738 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