Solved

What event triggers when using Tab Control in MS Access

Posted on 2013-10-22
8
769 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
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.

770 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