Tab Control - Invisible / Visible

McRoberts

Registered User.
Local time
Today, 07:37
Joined
Feb 7, 2006
Messages
28
I was able to use coding for making controls visible or not in the attached database.

I have a main form with a tab control that has 3 tabs with subforms in them.

What I am not able to do is in the Tab Control I want the 3rd tab to be invisible and on the second tab where it says “May we go through the questions now?”, I have a check box. When that check box is checked I want the 3rd tab to become visible.

I am having problems figuring out this code to reference the Tab Control Page.

Do you have any suggestions?

I can attached the database if necessary.

I appreciate any help that you can give me.
 
The tab control object has a Pages collection, and referencing that will give you what you need. Code might look a little as follows...
Code:
me.tab.pages("pgSomeName").visible = false
or, reference the collection by number
Code:
me.tab.pages(2).visible = true
 
Hi and thanks for your response.
I tried that code and the error is in .tab part of the code. It is not finding my tab control page when I am writing the code.
I am putting this code in the On Current event of the subform in the tab control. Am I putting it in the wrong spot?
I appreciate your help.
 
put this code on your checkbox...so that it goes on when you select the check box
 
I put it on my check box also and I am getting the same error.
Here is the exact code that I am using:
On Click of check box.
If Me.Survey_Complete = True Then
Me.tab.pages(2).visible = True
Me.tab.pages(2).enabled = True
Me.tab.pages(2).SetFocus
Else
Me.tab.pages(2).Visible = False
Me.tab.pages(2).Enabled = False
End If

The places that I highlight in bold is were the error is. It is not finding the tab control pages.
 
Check the name of your tab control?

Code:
Me.YourTabControlNameHere.Pages(SomePageNumberOrName).Visible = True

If you have no object on your form called "tab" that will give you problems. Also, no need to both disable and hide the page. Hiding it is enough.
Finally, given that Me.Survey_Complete is a boolean variable you can replace
Code:
If Me.Survey_Complete = True Then
Me.tab.pages(2).visible = True
Me.tab.pages(2).enabled = True
Me.[b]tab.pages(2)[b].SetFocus
Else
Me.tab.pages(2).Visible = False
Me.tab.pages(2).Enabled = False
End If
with
Code:
With Me.YourTab.Pages(YourPage)
[COLOR="Green"]  'if survey is complete page will be visible, if not, not visible[/COLOR]
  .Visible = Me.Survey_Complete
[COLOR="Green"]  'if visible, then set focus[/COLOR]
  If .Visible Then .SetFocus
End With

Hope this helps!
Mark
 

Users who are viewing this thread

Back
Top Bottom