Solved

What event triggers when using Tab Control in MS Access

Posted on 2013-10-22
8
730 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 119

Expert Comment

by:Rey Obrero
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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now