Solved

What event triggers when using Tab Control in MS Access

Posted on 2013-10-22
8
884 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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 48

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

695 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