By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,124 Members | 2,208 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,124 IT Pros & Developers. It's quick & easy.

Pages within pages using tab control

beacon
100+
P: 579
Hi,

I'm using Access 2003 and I'm trying to create a tab control that, upon pressing a command button, will take you to a second page of that particular tab.

For example, I have a tab control with six tabs/pages that will be labeled General Info, Informants, Cert of Trial Comp, Trial Comp Eval, Areas of Trial Comp. These are more like sections for the user to access to enter in data into fields that are placed within them.

The problem that I've encountered is that not all of the fields that I want to display will do so in the size of the window I have to use. What I thought about doing to remedy this was to create a second tab control with all of the same tabs/pages, but change the information on the pages where I have to go overboard. Then I figured I could create a command button that became active when I reached that tab and would allow the user to go to the second page of the tab, which, in essence, would only make the second tab control visible.

First off, the tab control doesn't activate the page when you click on the tab...you have to actually click somewhere on the page below the tab. Secondly, when I click the command button I created, all of the formatting goes haywire. All of the sudden, the second tab control has stretched beyond belief and the fields for the second tab control are intermingled with the fields from the first tab control.

Is there a better way to accomplish what I've set out to do? Is there any way to do what I'm attempting? Is there any way to control other objects by clicking on the tabs in the tab control? If 2 trains are travelling in opposite directions at 80 mph...oops, I got distracted.

Thanks for the help......
Dec 5 '07 #1
Share this Question
Share on Google+
27 Replies


Rabbit
Expert Mod 10K+
P: 12,383
Rather than 2 tab controls, why not overlap the controls on the same tab and have the control button toggle the visibility of the controls?
Dec 6 '07 #2

beacon
100+
P: 579
Rather than 2 tab controls, why not overlap the controls on the same tab and have the control button toggle the visibility of the controls?
That's a good idea...that's kind of what I was hoping to accomplish by using the 2 tab controls, but this makes sense. May take writing more code than I had hoped, but should look better.

As far as the control button is concerned...I don't want it to be visible unless a particular tab is selected by the user, but the tab control requires you, from what I've seen, to not only select the tab, but also click somewhere on the page. Is there a way to get the tab to be the focal point of the control to prevent this??

Thanks for the advice
Dec 6 '07 #3

Rabbit
Expert Mod 10K+
P: 12,383
I'm not sure what you mean but the tab control has an On Change event that triggers when a user moves between tabs. So you can use that or you can just put the button on the tab.
Dec 6 '07 #4

ADezii
Expert 5K+
P: 8,669
Hi,

I'm using Access 2003 and I'm trying to create a tab control that, upon pressing a command button, will take you to a second page of that particular tab.

For example, I have a tab control with six tabs/pages that will be labeled General Info, Informants, Cert of Trial Comp, Trial Comp Eval, Areas of Trial Comp. These are more like sections for the user to access to enter in data into fields that are placed within them.

The problem that I've encountered is that not all of the fields that I want to display will do so in the size of the window I have to use. What I thought about doing to remedy this was to create a second tab control with all of the same tabs/pages, but change the information on the pages where I have to go overboard. Then I figured I could create a command button that became active when I reached that tab and would allow the user to go to the second page of the tab, which, in essence, would only make the second tab control visible.

First off, the tab control doesn't activate the page when you click on the tab...you have to actually click somewhere on the page below the tab. Secondly, when I click the command button I created, all of the formatting goes haywire. All of the sudden, the second tab control has stretched beyond belief and the fields for the second tab control are intermingled with the fields from the first tab control.

Is there a better way to accomplish what I've set out to do? Is there any way to do what I'm attempting? Is there any way to control other objects by clicking on the tabs in the tab control? If 2 trains are travelling in opposite directions at 80 mph...oops, I got distracted.

Thanks for the help......
You may want to take a look at this:
Accessing Tabs on a Tab Control
Dec 7 '07 #5

beacon
100+
P: 579
You may want to take a look at this:
Accessing Tabs on a Tab Control
I checked out that link, but it wasn't exactly what I was looking for. It's all good. I'll just make due because it's really not a big deal.

I do have another problem that I think I need another set of eyes for. I tried out Rabbit's suggestion of using the one tab control and then making everything visible or invisible, but some of the controls that I've set up don't want to gain focus despite the code I've written.

Here's the gist...I have a tab control that has visible and invisible labels and textboxes. Off of the tab control I have 4 picture labels and 8 control buttons that indicate which of the labels and textboxes on the tab control need to be visible/enabled.

The pictures are of a disabled next page and previous page control and of an active next page and previous page control. These are used throughout.

On the 4th tab, I have a next page button and a previous page button that are working fine. They only progress forward or backward one step.

On the 5th tab, I have 3 next page buttons and 3 previous page buttons. Obviously, on the first page the next page button and picture should be visible and active, while the disabled previous page picture should be displayed. On the next 2 "pages", the next page and previous page buttons and pictures should be displayed, while on the last page the previous page button and picture should be displayed and the disabled next page picture should be showing.

I have a temporary placeholder label in the position I want each of these controls or labels to be when they are active. I also have temporary label placeholders for each of them (that are off to the side) that I have been returning the controls and labels to if they aren't being used.

The trouble I'm running into is that when you click on the next page button for "page" 3 (control TAB5NP3) the next page picture is visible, but the next page button for "page" 4 is not, despite the fact that I have written code to place it on top. Additionally, each of the previous page buttons, with the exception of the first previous page button (contol TAB5PP1) are doing the same thing.

I'm attaching my code, in the hope that someone can determine where my mistake is. Also, since I have limited Access VBA experience, if there's a better way to write some of the code I've written and you want to indulge me, please do.

**** I had to edit this message and attach my code to my next post because it wouldn't let me post what I have. I kept getting 2 error messages: 1 said that I needed to fill out the subject and message fields (which I did) and the other said that my post needed to be longer than 20 characters. Combine this post and the next post together and I'm pretty sure I destroyed the 20 character requirement. Sorry for "top-posting" if that's what it's called. I really did try everything I could to get it to work.
Dec 10 '07 #6

Rabbit
Expert Mod 10K+
P: 12,383
I stopped tracking what you were trying to do after a bit. You've made it overly complex. Here's what I use to navigate between tabs.

Expand|Select|Wrap|Line Numbers
  1. Private Sub but_Next_Click()
  2.     Select Case Me.MainTab
  3.         Case 0 To (Me.MainTab.Pages.Count - 2)
  4.             Me.MainTab.Pages(Me.MainTab + 1).SetFocus
  5.     End Select
  6. End Sub
  7.  
  8. Private Sub but_Prev_Click()
  9.     Select Case Me.MainTab
  10.         Case 1 To (Me.MainTab.Pages.Count - 1)
  11.             Me.MainTab.Pages(Me.MainTab - 1).SetFocus
  12.     End Select
  13. End Sub
  14.  
Dec 10 '07 #7

beacon
100+
P: 579
Ok...don't worry about it then. I must be in over my head. Maybe I can rig it somehow.
Dec 10 '07 #8

Rabbit
Expert Mod 10K+
P: 12,383
Ok...don't worry about it then. I must be in over my head. Maybe I can rig it somehow.
You don't have to rig it. Just use my code. it navigates through the tabs and only uses two buttons. If you need to do stuff beyond that, then we can modify it.
Dec 10 '07 #9

beacon
100+
P: 579
I don't understand what your code is doing though...

Are you saying that I should create extra pages in the tab control and have their visibility controlled by the next/previous page buttons? If so, I thought you were suggesting that I set each of the controls and labels on the page that I didn't want to use as not visible until I reached the click event that activates them.

Is creating extra pages with the tab control and setting them to not visible (with the same caption as another page) possible?
Dec 10 '07 #10

Rabbit
Expert Mod 10K+
P: 12,383
I don't understand what your code is doing though...

Are you saying that I should create extra pages in the tab control and have their visibility controlled by the next/previous page buttons? If so, I thought you were suggesting that I set each of the controls and labels on the page that I didn't want to use as not visible until I reached the click event that activates them.

Is creating extra pages with the tab control and setting them to not visible (with the same caption as another page) possible?
Are we not talking about a problem that is different from your control/label visibilty problem?

It sounded as if you wanted custom tab navigation buttons and you created a set for each page. I'm just saying you don't need a set of navigation buttons for each page. My code does it with 2 buttons.

If this is actually related to your original problem and not a problem in of itself, then I have misunderstood what you originally meant.

Yes, my original proposition was to set the visibility of the controls, but not when the page changes but when a button was clicked, which was what was originally requested no?

However, you may have stumbled upon an easier solution. Yes you can create two tabs, each with the same caption, but with a different name. And then you can just set the visibility of the tab.

tab = page just to clear confusion.
Dec 10 '07 #11

beacon
100+
P: 579
My original question/problem/headache was two-fold. First, the issue was that when you click on a tab, it doesn't actually activate that tab. You have to select the tab and then click somewhere below the tab, on what I'm gunna call the data portion of the tab, to get code to work.

For example, I created a Page1_Click event that would make a next page button visible and enabled. When you actually click on the tab though nothing happens. You have to click in the data portion of the tab for this event to work. That part of it isn't a big deal. It would be nice to know if it can be manipulated so that events would begin when the user clicks on the tab, instead of having to click the tab and then also click the data portion to get code to work.

The second part of it was, understandably, more confusing. I'm going to refrain from repeating that and just tell you my intentions now that I've got the multiple tab thing going.

Now, instead of having 6 tabs as I did initially, I have 10 tabs. The fourth tab actually consists of the 3rd and 4th page indices with the 3rd being the only one visible when the form loads. Creating a button to go back and forth between these 2 tabs/page indices is easy.

Where I start to have trouble is on the so called 5th tab, which starts with page index of 5 and goes through 8, with only 5 visible when the form loads. Here I want to be able to navigate forward and backward through these pages. I'm not sure if I could do this without having multiple control buttons, so I'm going to start working on it under the assumption that I can't. If it is possible and anyone wants to help me out with code...thanks. Otherwise, I keep going with what I know until I hit another roadblock.
Dec 10 '07 #12

Rabbit
Expert Mod 10K+
P: 12,383
My original question/problem/headache was two-fold. First, the issue was that when you click on a tab, it doesn't actually activate that tab. You have to select the tab and then click somewhere below the tab, on what I'm gunna call the data portion of the tab, to get code to work.

For example, I created a Page1_Click event that would make a next page button visible and enabled. When you actually click on the tab though nothing happens. You have to click in the data portion of the tab for this event to work. That part of it isn't a big deal. It would be nice to know if it can be manipulated so that events would begin when the user clicks on the tab, instead of having to click the tab and then also click the data portion to get code to work.

The second part of it was, understandably, more confusing. I'm going to refrain from repeating that and just tell you my intentions now that I've got the multiple tab thing going.

Now, instead of having 6 tabs as I did initially, I have 10 tabs. The fourth tab actually consists of the 3rd and 4th page indices with the 3rd being the only one visible when the form loads. Creating a button to go back and forth between these 2 tabs/page indices is easy.

Where I start to have trouble is on the so called 5th tab, which starts with page index of 5 and goes through 8, with only 5 visible when the form loads. Here I want to be able to navigate forward and backward through these pages. I'm not sure if I could do this without having multiple control buttons, so I'm going to start working on it under the assumption that I can't. If it is possible and anyone wants to help me out with code...thanks. Otherwise, I keep going with what I know until I hit another roadblock.
Here's the tricky thing about tabs, all the tabs are children of a master control called the tab control. This tab control is the object that holds the events and information relating the navigation inside the tab control. The tab/page events handle what happens inside the tab/page.

When you change pages, it is not the On Click event of the page that triggers, but the On Change event of the tab control.
Dec 10 '07 #13

beacon
100+
P: 579
Here's the tricky thing about tabs, all the tabs are children of a master control called the tab control. This tab control is the object that holds the events and information relating the navigation inside the tab control. The tab/page events handle what happens inside the tab/page.

When you change pages, it is not the On Click event of the page that triggers, but the On Change event of the tab control.
So how do you reference the tabs/pages if you use the OnChange event or is there a way? That's not what you were trying to show me with the code you wrote, is it?
Dec 10 '07 #14

beacon
100+
P: 579
I was able to get it to work using TabControl.Value = 3 where 3 is the index of the page I want to access.

When I switch back and forth using my next and previous page buttons it does some glitchy shake, but I'm sure that's because the tabs aren't in the exact same location and are having to switch with each other.
Dec 10 '07 #15

beacon
100+
P: 579
I spoke too soon...

I did get the tabs to work to the point where they will make something happen without having to click on the tab page.

I'm still having trouble with the control buttons though. I have 2 buttons on tab 4, one for next page and one for previous page. Then I have 3 next page buttons and 3 previous page buttons on tab 5.

Here's some code I wrote that worked fine for tab 4 until I wrote the procedure for tab 5. When I wrote the procedure for 5, everything I did for 4 basically stopped working.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3.  
  4. Private Sub NP_Click()
  5.     Me.Page4.Visible = False
  6.     With Me.Page41
  7.         .Visible = True
  8.         .Enabled = True
  9.         tab4t110.SetFocus
  10.     End With
  11. End Sub
  12.  
  13. Private Sub PP_Click()
  14.     Me.Page41.Visible = False
  15.     With Me.Page4
  16.         .Visible = True
  17.         .Enabled = True
  18.         tab4t1.SetFocus
  19.     End With
  20. End Sub
  21.  
  22. Private Sub TabCtl0_Change()
  23.  
  24.     If TabCtl0.Value = 3 Then
  25.         Me.NPpic.Visible = True
  26.         Me.DisNP.Visible = False
  27.         tab4t1.SetFocus
  28.         With Me.NP
  29.             .Top = Me.DisNP.Top
  30.             .Left = Me.DisNP.Left
  31.             .Visible = True
  32.             .Enabled = True
  33.         End With
  34.  
  35.     Else
  36.         Me.DisNP.Visible = True
  37.         Me.NPpic.Visible = False
  38.         With Me.tempbutton
  39.             .Visible = True
  40.             .Enabled = True
  41.             .SetFocus
  42.         End With
  43.         With Me.NP
  44.             .Top = Me.NPtemp.Top
  45.             .Left = Me.NPtemp.Left
  46.             .Visible = False
  47.             .Enabled = False
  48.         End With
  49.     End If
  50. End Sub
  51.  
  52. Private Sub TabCtl0_Change()
  53.     If TabCtl0.Value = 4 Then
  54.         Me.PPpic.Visible = True
  55.         Me.DisPP.Visible = False
  56.         With Me.PP
  57.             .Top = Me.DisPP.Top
  58.             .Left = Me.DisPP.Left
  59.             .Visible = True
  60.             .Enabled = True
  61.         End With
  62.     Else
  63.         Me.DisPP.Visible = True
  64.         Me.PPpic.Visible = False
  65.         With Me.PP
  66.             .Top = Me.PPtemp.Top
  67.             .Left = Me.PPtemp.Left
  68.             .Visible = False
  69.             .Enabled = False
  70.         End With
  71.     End If
  72. End Sub
  73.  
  74. Private Sub TabCtl0_Change()
  75.     If TabCtl0.Value = 5 Then
  76.         Me.NPpic.Visible = True
  77.         Me.DisNP.Visible = False
  78.         tab5t1.SetFocus
  79.         With Me.NP2
  80.             .Top = Me.DisNP.Top
  81.             .Left = Me.DisNP.Left
  82.             .Visible = True
  83.             .Enabled = True
  84.         End With
  85.  
  86.     Else
  87.         Me.DisNP.Visible = True
  88.         Me.NPpic.Visible = False
  89.         With Me.tempbutton
  90.             .Visible = True
  91.             .Enabled = True
  92.             .SetFocus
  93.         End With
  94.         With Me.NP2
  95.             .Top = Me.NP2temp.Top
  96.             .Left = Me.NP2temp.Left
  97.             .Visible = False
  98.             .Enabled = False
  99.         End With
  100.     End If
  101. End Sub
Eventually I'm going to have a click event for NP2, 3, and 4 and also for PP1, 2, 3. Unless, that is, there's a way that I can indicate to the control buttons that they should only control the tab pages for a specific tabcontrol.value.
Dec 10 '07 #16

Rabbit
Expert Mod 10K+
P: 12,383
You shouldn't have multiple subs with the same name. Plus, you should be able to do everything with 2 command buttons.

In this example I have 5 pages. 0, 1, 4, 5 are always visible. Of 2 and 3, only one is visible at any time.
Expand|Select|Wrap|Line Numbers
  1. Private Sub but_Next_Click()
  2.    Select Case Me.TabCtl0
  3.       Case 0, 3 To 4
  4.          Me.TabCtl0 = Me.TabCtl0 + 1
  5.       Case 1
  6.          Me.TabCtl0.Pages(2).Visible = True
  7.          Me.TabCtl0 = 2
  8.          Me.TabCtl0.Pages(3).Visible = False
  9.       Case 2
  10.          Me.TabCtl0.Pages(3).Visible = True
  11.          Me.TabCtl0 = 3
  12.          Me.TabCtl0.Pages(2).Visible = False
  13.    End Select
  14. End Sub
  15.  
  16. Private Sub but_Prev_Click()
  17.    Select Case Me.TabCtl0
  18.       Case 1 To 2, 5
  19.          Me.TabCtl0 = Me.TabCtl0 + 1
  20.       Case 3
  21.          Me.TabCtl0.Pages(2).Visible = True
  22.          Me.TabCtl0 = 2
  23.          Me.TabCtl0.Pages(3).Visible = False
  24.       Case 4
  25.          Me.TabCtl0.Pages(3).Visible = True
  26.          Me.TabCtl0 = 3
  27.          Me.TabCtl0.Pages(2).Visible = False
  28.    End Select
  29. End Sub
  30.  
Dec 10 '07 #17

beacon
100+
P: 579
Ok...I'm with you on what you are doing. Using a switch statement definitely makes more sense, but I'm not exactly sure how it reads. Why do you have Case 0, 3 to 4 and then Case 1 to 2, 5? I'm confused by how you skip case numbers and your syntax, probably because I've never seen it before.

Also, if I have pages that extend beyond just one extra page, will my cases be much different?

Thanks again Rabbit for your help. By the way, do you know of any good reference books for Access that focus mainly on the vb aspect of it? It's problems like the ones I've been having that you don't find in these Microsoft Press books.
Dec 11 '07 #18

beacon
100+
P: 579
Should I also use a switch or select statement (sorry, I'm studying C++ too) in my TabCtl0_Change() method? I'm trying out your last suggestion, but I think that because I don't exactly understand what the code is saying, I'm having a hard time modifying it to match up with my stuff considering the fact that I have one tab that consists of 4 pages where only one is visible at a time.

By the way, I don't want the next or previous page buttons to control all of the tabs. I just want them to control the tabs that will have multiple pages.

This may be part of what's confusing me about your code. It looks like you are using the buttons to control all of the movement between all of the tabs. If that's the case, I'm trying to not have the buttons even be visible until you reach the first tab with multiple pages. I have a pic of a disabled button that will be used the rest of the time.
Dec 11 '07 #19

Rabbit
Expert Mod 10K+
P: 12,383
Ok...I'm with you on what you are doing. Using a switch statement definitely makes more sense, but I'm not exactly sure how it reads. Why do you have Case 0, 3 to 4 and then Case 1 to 2, 5? I'm confused by how you skip case numbers and your syntax, probably because I've never seen it before.

Also, if I have pages that extend beyond just one extra page, will my cases be much different?

Thanks again Rabbit for your help. By the way, do you know of any good reference books for Access that focus mainly on the vb aspect of it? It's problems like the ones I've been having that you don't find in these Microsoft Press books.
Sorry, you'll find commented code below.

You cases won't be too much different, you'll just have to tweak the numbers slightly.

Can't really help there. I mostly learned by messing around, google, and the help files, which are excellent. The Access/VBA help files are some of the best I've seen. Usually help files are too technical or too general to be of any help.

In this example I have 5 pages. 0, 1, 4, 5 are always visible. Of 2 and 3, only one is visible at any time.
Expand|Select|Wrap|Line Numbers
  1. Private Sub but_Next_Click()
  2.    Select Case Me.TabCtl0
  3.       Case 0, 3 To 4 ' If the page is 0, 3, or 4: Move to next page
  4.          Me.TabCtl0 = Me.TabCtl0 + 1
  5.       Case 1 ' If page is 1, then I have to make sure page 2 is visible because they might have been on page 2 earlier, clicked next, making page 2 invisible and page 3 visible, then clicked on page 1 and click next again but now page 2 is not visible.
  6.          Me.TabCtl0.Pages(2).Visible = True
  7.          Me.TabCtl0 = 2
  8.          Me.TabCtl0.Pages(3).Visible = False
  9.       Case 2 ' If page is 2, then make page 3 visible and page 2 invisible.
  10.          Me.TabCtl0.Pages(3).Visible = True
  11.          Me.TabCtl0 = 3
  12.          Me.TabCtl0.Pages(2).Visible = False
  13.    End Select
  14. End Sub
  15.  
  16. Private Sub but_Prev_Click()
  17.    Select Case Me.TabCtl0
  18.       Case 1 To 2, 5 ' If page is 1, 2, or 5: Move to previous page. The reason 2 is in here is because you can't be on 2 unless it's visible.
  19.          Me.TabCtl0 = Me.TabCtl0 - 1 ' This should've been minus not plus, my mistake.
  20.       Case 3 ' Same reasoning as Case 2 from the first sub.
  21.          Me.TabCtl0.Pages(2).Visible = True
  22.          Me.TabCtl0 = 2
  23.          Me.TabCtl0.Pages(3).Visible = False
  24.       Case 4 'Same reasoning as Case 1 from the first sub except in the reverse direction.
  25.          Me.TabCtl0.Pages(3).Visible = True
  26.          Me.TabCtl0 = 3
  27.          Me.TabCtl0.Pages(2).Visible = False
  28.    End Select
  29. End Sub
  30.  
Should I also use a switch or select statement (sorry, I'm studying C++ too) in my TabCtl0_Change() method? I'm trying out your last suggestion, but I think that because I don't exactly understand what the code is saying, I'm having a hard time modifying it to match up with my stuff considering the fact that I have one tab that consists of 4 pages where only one is visible at a time.

By the way, I don't want the next or previous page buttons to control all of the tabs. I just want them to control the tabs that will have multiple pages.

This may be part of what's confusing me about your code. It looks like you are using the buttons to control all of the movement between all of the tabs. If that's the case, I'm trying to not have the buttons even be visible until you reach the first tab with multiple pages. I have a pic of a disabled button that will be used the rest of the time.
You won't have to use the TabCtl0_Change method unless you need it to do something when they click on a certain tab. If you're going to use the buttons to navigate, and navigation is all you need, then you don't need to use the TabCtl0_Change method.

In this case, you can either have two buttons on each of those pages and each of those buttons either opens up the next page or previous page. This means 8 buttons and 8 _Click methods.

Something a little more challenging but cleaner is to use two buttons that aren't on any of the pages. In this case you will use the TabCtl0_Change method to toggle the button's visibility. Then you see what page they're on and depending on which button they clicked, it'll open up the next/previous page.
Dec 11 '07 #20

beacon
100+
P: 579
That clears things up, if for no other reason than because I apparently wasn't clear on some of what I'm doing.

I have multiple buttons (8, I think) and they are all off of the tab control. I was using the change() method to determine which page I'm on so I could have a particular button slide over into position.

Now I think I just need 2 next page buttons and 2 previous page buttons and can actually use a switch for the pages themselves instead of the tab control.

I think I'm still going to use the change() method because I want the user to actually click each of the tabs and only click the next page button if there are additional pages with the same caption as another....a sub-page, if you will.

Are you talking about the Help on the toolbar in Access? Did you just use the search for topic option or are you talking about something else?
Dec 11 '07 #21

Rabbit
Expert Mod 10K+
P: 12,383
If you're going to go with the 8 buttons route, just put 2 on each page, then you don't have to worry about which one is visible.

If you go with just two, then you will need the Change event to make the buttons visible when you need them. Just so you know, the Change event does not trigger if you change the page through code.

I mostly use the context sensitive help. In the VBA editor if there's txtBox1_AfterUpdate, and I don't know when After Update occurs, I will hightlight AfterUpdate and press F1. In Access, if i'm in a property I don't understand, I'll click on it and then press F1.
Dec 11 '07 #22

beacon
100+
P: 579
I used the switch, but I'm running into the same problem I ran into when I used the nested if statements.

When I get to the 5th tab (with the caption Areas of Trial Competency...the one with 3 others like it that are initially not visible), I can select the next page button, but once I get to the next page, and all subsequent pages, the previous page buttons aren't showing.

I have a picture I use when the buttons are active (NPpic and PPpic) and a picture for when they aren't active (DisNP and DisPP). I thought that maybe I should drop the picture into the command and just use the .enabled property, but I'm not sure if that's the reason why the button isn't showing. It makes me wonder, if I do change up the pictures will that fix the problem or are the pictures not the problem in the first place? It probably is and has resulted in me fighting a never ending battle with the z-axis to bring certain items to the front.

Any ideas?

Expand|Select|Wrap|Line Numbers
  1. Private Sub NP_Click()
  2.     Select Case Me.TabCtl0
  3.         Case 3
  4.             Me.Page41.Visible = True
  5.             Me.tab4t110.SetFocus
  6.             Me.Page4.Visible = False
  7.         Case 4
  8.             Me.Page4.Visible = True
  9.             Me.tab4t1.SetFocus
  10.             Me.Page41.Visible = False
  11.     End Select
  12. End Sub
  13.  
  14. Private Sub NP2_Click()
  15.     Select Case Me.TabCtl0
  16.         Case 5
  17.             Me.Page51.Visible = True
  18.             Me.tab51t1.SetFocus
  19.             Me.Page5.Visible = False
  20.         Case 6
  21.             Me.Page52.Visible = True
  22.             Me.tab52t1.SetFocus
  23.             Me.Page51.Visible = False
  24.         Case 7
  25.             Me.Page53.Visible = True
  26.             Me.tab53t1.SetFocus
  27.             Me.Page52.Visible = False
  28.         Case 8
  29.             Me.DisNP.Visible = True
  30.     End Select
  31. End Sub
  32.  
  33. Private Sub PP_Click()
  34.     Select Case Me.TabCtl0
  35.         Case 4
  36.             Me.Page4.Visible = True
  37.             Me.tab4t1.SetFocus
  38.             Me.Page41.Visible = False
  39.         Case 3
  40.             Me.Page41.Visible = True
  41.             Me.tab4t110.SetFocus
  42.             Me.Page4.Visible = False
  43.     End Select
  44. End Sub
  45.  
  46. Private Sub PP2_Click()
  47.     Select Case Me.TabCtl0
  48.         Case 5
  49.             Me.DisPP.Visible = True
  50.         Case 6
  51.             Me.Page5.Visible = True
  52.             Me.tab5t1.SetFocus
  53.             Me.Page51.Visible = False
  54.         Case 7
  55.             Me.Page51.Visible = True
  56.             Me.tab51t1.SetFocus
  57.             Me.Page52.Visible = False
  58.         Case 8
  59.             Me.Page52.Visible = True
  60.             Me.tab52t1.SetFocus
  61.             Me.Page53.Visible = False
  62.     End Select
  63. End Sub
  64.  
  65. Private Sub TabCtl0_Change()
  66.     Select Case Me.TabCtl0
  67.         Case 0 To 2, 9
  68.             Me.DisNP.Visible = True
  69.             Me.DisPP.Visible = True
  70.             Me.NPpic.Visible = False
  71.             Me.PPpic.Visible = False
  72.             With Me.NP
  73.                 .Top = Me.NPtemp.Top
  74.                 .Left = Me.NPtemp.Left
  75.                 .Visible = False
  76.                 .Enabled = False
  77.             End With
  78.             With Me.PP
  79.                 .Top = Me.PPtemp.Top
  80.                 .Left = Me.PPtemp.Left
  81.                 .Visible = False
  82.                 .Enabled = False
  83.             End With
  84.         Case 3
  85.             Me.NPpic.Visible = True
  86.             Me.DisPP.Visible = True
  87.             With Me.NP
  88.                 .Top = Me.DisNP.Top
  89.                 .Left = Me.DisNP.Left
  90.                 .Visible = True
  91.                 .Enabled = True
  92.             End With
  93.             With Me.PP
  94.                 .Top = Me.PPtemp.Top
  95.                 .Left = Me.PPtemp.Left
  96.                 .Visible = False
  97.                 .Enabled = False
  98.             End With
  99.             Me.DisNP.Visible = False
  100.             Me.PPpic.Visible = False
  101.         Case 4
  102.             Me.DisNP.Visible = True
  103.             Me.PPpic.Visible = True
  104.             With Me.PP
  105.                 .Top = Me.DisPP.Top
  106.                 .Left = Me.DisPP.Left
  107.                 .Visible = True
  108.                 .Enabled = True
  109.             End With
  110.             With Me.NP
  111.                 .Top = Me.NPtemp.Top
  112.                 .Left = Me.NPtemp.Left
  113.                 .Visible = False
  114.                 .Enabled = False
  115.             End With
  116.             Me.DisPP.Visible = False
  117.             Me.NPpic.Visible = False
  118.         Case 5
  119.             With Me.NP2
  120.                 .Top = Me.DisNP.Top
  121.                 .Left = Me.DisNP.Left
  122.                 .Visible = True
  123.                 .Enabled = True
  124.             End With
  125.             Me.NPpic.Visible = True
  126.             Me.DisPP.Visible = True
  127.             With Me.PP2
  128.                 .Top = Me.PP2temp.Top
  129.                 .Left = Me.PP2temp.Left
  130.                 .Visible = False
  131.                 .Enabled = False
  132.             End With
  133.             Me.DisNP.Visible = False
  134.             Me.PPpic.Visible = False
  135.         Case 6
  136.             With Me.NP2
  137.                 .Top = Me.DisNP.Top
  138.                 .Left = Me.DisNP.Left
  139.                 .Visible = True
  140.                 .Enabled = True
  141.             With Me.PP2
  142.                 .Top = Me.DisPP.Top
  143.                 .Left = Me.DisPP.Left
  144.                 .Visible = True
  145.                 .Enabled = True
  146.                 .SetFocus
  147.             End With
  148.             Me.NPpic.Visible = True
  149.             Me.PPpic.Visible = True
  150.             Me.DisNP.Visible = False
  151.             Me.DisPP.Visible = False
  152.         Case 7
  153.             With Me.NP2
  154.                 .Top = Me.DisNP.Top
  155.                 .Left = Me.DisNP.Left
  156.                 .Visible = True
  157.                 .Enabled = True
  158.             End With
  159.             With Me.PP2
  160.                 .Top = Me.DisPP.Top
  161.                 .Left = Me.DisPP.Left
  162.                 .Visible = True
  163.                 .Enabled = True
  164.             End With
  165.             Me.NPpic.Visible = True
  166.             Me.PPpic.Visible = True
  167.             Me.DisNP.Visible = False
  168.             Me.DisPP.Visible = False
  169.         Case 8
  170.             With Me.PP2
  171.                 .Top = Me.DisPP.Top
  172.                 .Left = Me.DisPP.Left
  173.                 .Visible = True
  174.                 .Enabled = True
  175.             End With
  176.             Me.DisNP.Visible = True
  177.             Me.PPpic.Visible = True
  178.             With Me.NP2
  179.                 .Top = Me.NP2temp.Top
  180.                 .Left = Me.NP2temp.Left
  181.                 .Visible = False
  182.                 .Enabled = False
  183.             End With
  184.             Me.NPpic.Visible = False
  185.             Me.DisPP.Visible = False
  186.     End Select
  187. End Sub
  188.  
Dec 11 '07 #23

Rabbit
Expert Mod 10K+
P: 12,383
I can't follow what you're doing with the code.

You're referencing all these controls but I don't know what they're supposed to be.

Ok, so I have a tab control TabCtl0. It has 5 pages. Page 0 and Page 4 are always visible. At any time, of Page1, Page2, and Page3, only one is visible. As a default, Page1 is visible.

I have two buttons that is not on the tab control: but_Next and but_Prev.

Expand|Select|Wrap|Line Numbers
  1. Private Sub TabCtl0_Change()
  2.    If TabCtl0 >= 1 And TabCtl <= 3 Then
  3.       Me.but_Next.Visible = True
  4.       Me.but_Prev.Visible = True
  5.    Else
  6.       Me.but_Next.Visible = False
  7.       Me.but_Prev.Visible = False
  8.    End If
  9. End Sub
  10.  
  11. Private Sub but_Next_Click()
  12.    Select Case Me.TabCtl0
  13.       Case 1
  14.          Me.TabCtl0.Pages(2).Visible = True
  15.          Me.TabCtl0 = 2
  16.          Me.TabCtl0.Pages(1).Visible = False
  17.       Case 2
  18.          Me.TabCtl0.Pages(3).Visible = True
  19.          Me.TabCtl0 = 3
  20.          Me.TabCtl0.Pages(2).Visible = False
  21.    End Select
  22. End Sub
  23.  
  24. Private Sub but_Next_Click()
  25.    Select Case Me.TabCtl0
  26.       Case 3
  27.          Me.TabCtl0.Pages(2).Visible = True
  28.          Me.TabCtl0 = 2
  29.          Me.TabCtl0.Pages(3).Visible = False
  30.       Case 2
  31.          Me.TabCtl0.Pages(1).Visible = True
  32.          Me.TabCtl0 = 1
  33.          Me.TabCtl0.Pages(2).Visible = False
  34.    End Select
  35. End Sub
  36.  
Dec 11 '07 #24

beacon
100+
P: 579
Hey Rabbit,

I finally got it to work. The problem the whole time was that I had 2 pictures of buttons that I was trying to use underneath a transparent button and, unfortunately, their precedence sometimes got mixed up with the buttons.

Anyway, I embedded the pictures into the buttons and everything came out perfect.

I'm going to provide a finished version with comments either later today or sometime tomorrow.

Thank you again Rabbit for taking so much time out of your schedule to help me out with this. I can honestly say that I've learned more in the past few days working on this than I would have ever expected to need to know to accomplish what I originally set out to do.

It's frustrating when you're used to using containers in VB6 and then don't have that option entirely in Access and have to find ways around it.

Anyway...keep it real and hopefully you won't hear from me for a while.

*beacon*
Dec 11 '07 #25

Rabbit
Expert Mod 10K+
P: 12,383
Not a problem, good luck.
Dec 12 '07 #26

P: 1
Hi, I just wanted to say thanks for the link earlier in this thread, it was what I needed, the link with the following

Me!TabCtl0.Pages(0).SetFocus

I created a button on each of the pages but would it be possible to place the same outside of the tabbed form for example on the main form or does Me! only exist on the tabbed form.

if so how can i do it?

Moss
Feb 6 '08 #27

ADezii
Expert 5K+
P: 8,669
Hi, I just wanted to say thanks for the link earlier in this thread, it was what I needed, the link with the following

Me!TabCtl0.Pages(0).SetFocus

I created a button on each of the pages but would it be possible to place the same outside of the tabbed form for example on the main form or does Me! only exist on the tabbed form.

if so how can i do it?

Moss
The same syntax can be used outside of the Tab Control, but within the confines of the Parent Form. If you wish to produce the same effect from another Form however, the syntax would be:
Expand|Select|Wrap|Line Numbers
  1. Forms!<Your Form Name>![TabCtl0].Pages(0).SetFocus
Feb 7 '08 #28

Post your reply

Sign in to post your reply or Sign up for a free account.