Changing tab page and tab control without firing selectedindex event

Well that is what I am attemping. I already have an event that fires when the user manually clicks each tab page, basically executing some SQL statements depending on what tab page they are on. So what I want to do is when someone is clicking on a datagrid row it shows the particular tabpage. Well I can do that with this line of code.

 Me.TabPage1.Show()

The problem is the darn tab page clicker up top still shows your on the datagrid page (tabpage3) , when you are on tabpage1, the tabcontrol just does not show correctly. What I cannot do is this

Me.TabControl1.SelectedIndex = 0

If I fire that event then it issues new select statements and that will mess me up. Is there anyway to focus on the tabindex without firing that off ?

reefcrazedAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Declare yourself a boolean flag that you set to True when you want to use this statement:

    Me.TabControl1.SelectedIndex = 0

Then check the flag in your event.  If it is true, then simply reset it back to false, and exit the sub...otherwise continue with your SQL code.
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
reefcrazedAuthor Commented:
You mean make it a public variable so all of the subroutines could us it. How about passing an optional boolean parameter into the subroutine, I am thinking that would work too. I am not at work right now to try it but going to on Monday.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.