Question Buttons

Something like this:
Code:
Private Sub YourTablControlNameHere_Change()
    Select Case Me.YourTablControlNameHere
    Case 0
        MsgBox "You clicked Tab 1"
    Case 1
        MsgBox "You clicked Tab 2"
    Case Else
        MsgBox "You shouldn't see this but it is here in case something doesn't get assigned"
    End Select
End Sub

And you can put your code to do whatever based on which tab was selected in there. I just used message boxes as kind of a place holder and to demonstrate.
 
Something like this:
Code:
Private Sub YourTablControlNameHere_Change()
    Select Case Me.YourTablControlNameHere
    Case 0
        MsgBox "You clicked Tab 1"
    Case 1
        MsgBox "You clicked Tab 2"
    Case Else
        MsgBox "You shouldn't see this but it is here in case something doesn't get assigned"
    End Select
End Sub
And you can put your code to do whatever based on which tab was selected in there. I just used message boxes as kind of a place holder and to demonstrate.

By George, I think I've got it!

Thanks heaps for the help, truly appreciated.
 
try this:
Code:
Private Sub TabCtl1_[COLOR=Red][B]Change[/B][/COLOR]()
     MsgBox "tab page: " & TabCtl1.value
End Sub

Thanks, Realllllly appreciated the help.
 
not sure exactly what you are doing, but generally, if you use a transparent overlay, the control underneath has to be enabled=no, locked=yes, so that you cant tab INTO it - otherwise it does get brought up over the transparent button.
 
not sure exactly what you are doing, but generally, if you use a transparent overlay, the control underneath has to be enabled=no, locked=yes, so that you cant tab INTO it - otherwise it does get brought up over the transparent button.

I wasn't sure what I was doing either, smiling, but I had not realised this - it is good to know, thankyou very much.
 
You implemented Bob's solution I'm guessing? Glad to know you got it working. :)

Yes, I did use Bob's solution but that is not the point. You kindly tried to help and I am a newbie who needs all the help he can get. The simply fact is I mostly understood Bob's but did not quite understand yours. Why, because this is the first time I have tried to write code in Access. In fact it took me some time to work out that I needed to do things like put in Case O [and leave it blank so the tab would continue to work], but only change the tab I wanted working, then too I had no idea I had to use a DoCmd but worked that out fairly quickly, and I even worked out I had to End Select. So a big learning curve for me, and none of that would have been possible if it had not been for your help and Bob's. Thanks again, I really mean it.
 
Yes, I did use Bob's solution but that is not the point. You kindly tried to help and I am a newbie who needs all the help he can get. The simply fact is I mostly understood Bob's but did not quite understand yours. Why, because this is the first time I have tried to write code in Access. In fact it took me some time to work out that I needed to do things like put in Case O [and leave it blank so the tab would continue to work], but only change the tab I wanted working, then too I had no idea I had to use a DoCmd but worked that out fairly quickly, and I even worked out I had to End Select. So a big learning curve for me, and none of that would have been possible if it had not been for your help and Bob's. Thanks again, I really mean it.
I'm glad you took the plunge and got your hands dirty, so to speak. By doing it yourself and researching further you got to understand it better.

Good job!! :)
 
Here is one of the solutions that I used. I have decided that when users open this database they will load all relevant forms at the start [Autoexec]. This takes a little time, but I thought that better than there being delays continuously while using the database opening and closing forms [I don't close forms but simply hide the tabs]. Because of this the first DoCmd I use is to go to the first TAB of the form that I am navigating from, as if you return to that form later it returns to the blank page of the TAB you initially clicked on when navigating. I was not sure what difference in this case there was between using gotocontrol or gotopage, so I used gotocontrol.

Any comments are appreciated.

Private Sub CustomersTabs_Change()
Select Case Me.CustomersTabs
Case 0
Case 1
Case 2
Case 3
Case 4
Case 5
Case 6
Case 7
DoCmd.GoToControl "Eligible People"
DoCmd.OpenForm "New Business Registration"
DoCmd.GoToControl "New Business Registration"
Case 8
DoCmd.GoToControl "Eligible People"
DoCmd.OpenForm "Registration"
DoCmd.GoToControl "New Product -Scheme"
Case 9
Case 10
Case Else
MsgBox "We'll that didn't work, did it?"
End Select
End Sub
 
I'm not entirely clear on your GoToControl scenario.

By the way in your case statements, for those that you don't use or for those that perform the same function, you can group them together by using a range (TO) or writing each number separated by a comma. Here:

Code:
Private Sub CustomersTabs_Change()
    Select Case Me.CustomersTabs
        Case 0 to 6, 9 to 10
        Case 7
            DoCmd.GoToControl "Eligible People"
            DoCmd.OpenForm "New Business Registration"
            DoCmd.GoToControl "New Business Registration"
        Case 8
            DoCmd.GoToControl "Eligible People"
            DoCmd.OpenForm "Registration"
            DoCmd.GoToControl "New Product -Scheme"
        Case Else
            MsgBox "We'll that didn't work, did it?"
    End Select
End Sub
 
Last edited:
Also, you do NOT need to handle one if you don't have code to run. If you had 5 tabs and only wanted two events - on tab 3 and 5 you could use:
Code:
Select Case myTabControl
Case 2 ' zero based so tab three is index of 2
  'Do something based on tab 3
Case 4 
  ' do something based on tab 5
End Select

So, you don't need to handle any others if you don't have anything to handle.
 
Thanks folks for all the help. I have appreciated and found helpful all the comments, by all of you. There is a steep learning curve to all of this, and that is why the help you so freely give makes such a huge difference. Thanks.
 

Users who are viewing this thread

Back
Top Bottom