How to hide tabs and make them appear after a specific optionbutton is selected?

lummers picture lummers · Jul 10, 2014 · Viewed 9.3k times · Source

I posted earlier, but since have made some good progress and figured some stuff out by myself!

I have nearly finished my project, but need to make the last real bit of code, then just some general tidying up.

What I want to do

  • I currently have two page in a MultiPage userform - one called 'main' and one called 'extra
  • I want Main to always be shown to the user
  • I want Extra to be hidden and for this page to be shown automatically under a specific condition

I have a question on my userform (using Option Buttons):

"Did the customer ask about an extra product today?"

If the answer to this question is no

When the user hits the command button (after filling out the rest of the form), do nothing special - just return all the values to the worksheet.

If the answer is yes

When the user hits the command button, I want them to be taken to the 'extra' page. They will fill out some additional check-boxes, then hit another command box, which will return the info from both the 'main' and 'extra' sheets together, into the same row of the worksheet.

In brief: I want my 'extra' tab to be hidden, only to appear when 'yes' is selected, and for the results all to go back to the worksheet. If you want to see my workbook:

https://drive.google.com/file/d/0B2F...it?usp=sharing

Can this be done? Thank you for your help :D

How I have hidden my Pages

  • I have changed the properties of the multipage to : "Style: fmTabStyleNone."

Now I just need the code to make my command button send the user to the next page, if required.

This isn't working for me. Any ideas??

If ProductEnquiryYes.Value = True Then
    With MultiPage1
        If .SelectedItem.Index < .Pages.Count - 1 Then
            .Value = .SelectedItem.Index + 1
        End If
    End With
End If 

Answer

user3514930 picture user3514930 · Jul 10, 2014

You can use the propriety Visible.
If the Tabs name is **TabStrip1:**

TabStrip1.Tabs(1).Visible = False

hide the second Tab. The Index Start From 0 to n-1 tabs.
When you Show, you can also active the tabs with:

TabStrip1.Tabs(1).Visible = True
TabStrip1.Value = 1

With Multipages:

MultiPage1.Pages(1).Visible = True
MultiPage1.Value = 1