Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing multi-pages yclhk Excel Discussion (Misc queries) 1 November 9th 09 04:50 PM
Why does Listview control shift to top on multi-page form? Matt[_41_] Excel Programming 1 September 1st 06 08:27 PM
Print all pages in a Multi page userform Alro Excel Programming 5 September 6th 05 10:49 PM
I want to print multi pages on one page. Laurie Excel Discussion (Misc queries) 2 August 24th 05 11:44 AM
how do i set up multi page user form Davidrowland88 Excel Discussion (Misc queries) 1 March 3rd 05 07:39 PM


All times are GMT +1. The time now is 08:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"