![]() |
Hiding some pages on multi page form
I have a multipage form used to colloect user data. I would like to hide some
of the pages and show them only if a valid password has been entered. Can anyone help? -- AJM1949 |
Hiding some pages on multi page form
I created a small userform with 3 commandbuttons, a multipage with 5 pages, and
a textbox. commandbutton1 and textbox1 were used to get the password. commandbutton2 was used to cancel (and unload the form) commandbutton3 was used as the "real" ok button This is the code I had under the userform: Option Explicit Private Sub CommandButton1_Click() Const CorrectPWD As String = "hi" Dim iCtr As Long Dim myPagesToSee() As Boolean ReDim myPagesToSee(0 To Me.MultiPage1.Pages.Count - 1) 'hide the password box and its button Me.TextBox1.Visible = False Me.CommandButton1.Visible = False For iCtr = 0 To Me.MultiPage1.Pages.Count - 1 'default to show the page myPagesToSee(iCtr) = True Next iCtr If Me.TextBox1.Value = CorrectPWD Then 'ok to see everything, don't change anything Else 'my test choices to hide (showing 1 & 2) myPagesToSee(0) = False myPagesToSee(3) = False myPagesToSee(4) = False End If For iCtr = 0 To Me.MultiPage1.Pages.Count - 1 Me.MultiPage1.Pages(iCtr).Visible = myPagesToSee(iCtr) Next iCtr Me.CommandButton2.Visible = True Me.MultiPage1.Visible = True End Sub Private Sub CommandButton3_Click() 'always cancel Unload Me End Sub Private Sub UserForm_Initialize() 'hide all the multipage MultiPage1.Visible = False Me.TextBox1.Visible = True With Me.CommandButton1 .Visible = True .Caption = "Ok" End With With Me.CommandButton2 .Visible = False .Caption = "Ok" End With With Me.CommandButton3 .Visible = True .Caption = "Cancel" End With End Sub AJM1949 wrote: I have a multipage form used to colloect user data. I would like to hide some of the pages and show them only if a valid password has been entered. Can anyone help? -- AJM1949 -- Dave Peterson |
All times are GMT +1. The time now is 11:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com