Solved

What event triggers when using Tab Control in MS Access

Posted on 2013-10-22
8
806 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
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

821 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