Multipage default open

W

Whois Clinton

Hi,

I am trying to set a default opening page for the multipage on a userform.
When I use:

Private Sub MultiPage1_Change()
UserForm1.MultiPage1.Value = 0
End Sub

OR

Private Sub MultiPage1_Change()
MultiPage1.Value = 0
End Sub

The dafult still does not work and it causes the labelling tabs to not work
correctly. I have to click it twice, 1st changes the tab appearnce 2nd
changes the actual page.
I would simply like it to always open on the first page.

Thanks in advance,
Matt
 
C

Chip Pearson

I don't think you want to be using the Change event. You can specify
the default opening page in the designer's Properties window for the
MultiPage by changing the Value property Or, you can do it with code
when the form is loaded.

Private Sub UserForm_Initialize()
With Me.MultiPage1
.Value = 1 ' 0-based. Page1=0, Page2=1, etc
End With
End Sub

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
W

Whois Clinton

I tried that but came up with the same problem. Here is the complete codes
assocaited with opening the userform. I also have this linked to a command
button to start it, if that matters. I have tried inserting the line
regarding multipage value=0 in the first Sub section. That hasn't helped
either. This is my first userform so I assume it is a beginner mistake.

Thanks for your time,
Clint


Option Explicit
Sub OpenUserfrm1()
UserForm1.Show
End Sub

Private Sub UserForm_Initialize()
'note page numbers start from 0
Me.MultiPage1.Value = 0
End Sub
 
W

Whois Clinton

I tried adding the code in with the initializing code.
ORIGINAL OPENING CODE

Option Explicit
Sub OpenUserfrm1()
UserForm1.Show
End Sub

Tried to add as follows:
Option Explicit
Sub OpenUserfrm1()
UserForm1.Show
End Sub
Private Sub UserForm_Initialize()
With Me.MultiPage1.Value = 1 ' 0-based. Page1=0, Page2=1, etc
End With
End Sub

That is not working either. Nor is adding the code in the set below which
controls the tools on the form. What am I missing?


Option Explicit

Private Sub CommandButton2_Click()
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
comboxResidentialList.Value = "Choose from below"

UserForm1.Hide
End Sub

Private Sub Commandbutton1_click()

Range("A1").Value = TextBox1.Value
Range("B1").Value = TextBox2.Value
Range("C1").Value = TextBox3.Value
Range("D1").Value = comboxResidentialList.Value
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
comboxResidentialList.Value = "Choose from below"
UserForm1.Hide

End Sub
Private Sub ListBox1_Click()

End Sub
Private Sub MultiPage1_Change()

End Sub

Private Sub UserForm_Click()

End Sub
 
W

Whois Clinton

THanks Roy that got me to the right spot but now returns:

Compile error:
With object must be user-defined type, Object, or Variant
 
W

Whois Clinton

No errors now but the user form still opens to whichever page was last
active. Just to be sure I am doing this right here is the exact code for the
user form:

Option Explicit

Private Sub CommandButton2_Click()
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
comboxResidentialList.Value = "Choose from below"
UserForm1.Hide
End Sub

Private Sub Commandbutton1_click()

Range("A1").Value = TextBox1.Value
Range("B1").Value = TextBox2.Value
Range("C1").Value = TextBox3.Value
Range("D1").Value = comboxResidentialList.Value
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
comboxResidentialList.Value = "Choose from below"
UserForm1.Hide

End Sub
Private Sub ListBox1_Click()

End Sub

Private Sub Label1_Click()

End Sub

Private Sub MultiPage1_Change()

End Sub

Private Sub UserForm_Click()

End Sub

Private Sub UserForm_Initialize()
With Me
.MultiPage1.Value = 0 ' 0-based. Page1=0, Page2=1, etc
End With

End Sub

Both codes put into initailze sub have no effect. Sorry it isn't working yet.
thanks even more!!
Clint
 
C

Chip Pearson

The form's Initialize event runs only when the form is loaded into
memory. If you close out the form using

UserForm1.Hide

the form is still loaded into memory and when shown again is only made
visible, not loaded, so the Initialize event won't run. You can dump
the form out of memory using

Unload UserForm1

This dumps the form, so the next time you Show it, it is reloaded and
the Initialize event will execute.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
W

Whois Clinton

Thanks again Chip, I have used your site quite often. Greatly appreciate the
explanation too, it will save me questions in the future.
Clint
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

multipage 2
Excel VBA Multipage 0
Deactivating Multipage Change Event 2
dynamic multipage 1
Can't trigger Keydown event 3
MultiPage Page Order 2
Multipage Buttons? 1
change label on multipage 3

Top