new instances of nested controls

N

nytrex

Hoping some fo your experts out there can help.

I'm working on an application that has a multipage control, with
several controls within it.

Depending on the value of a variable I would like to copy and paste
that multipaga control (with the nested controls in it) on the userform
x number of times.

I know I could easily create many 20 or so copies of the multipage
control at deisgn time and just hide the ones I don't need, but this
seems like a rather crude method of implementing what I want to do

Is there an easy way replicating a multipage control (with the nested
controls) several times within a userform?

I would appreciate any help you can give.

Regards
 
P

Peter T

' in say form initialize event
Dim newPage As Page
Dim nPages As Long
Dim i As Long

With Me.MultiPage1
nPages = .Count
.Pages(0).Controls.Copy ' copy first page

For i = 1 To 4 ' 20
Set newPage = .Pages.Add("Page" & (nPages + i), _
"New-Page " & (nPages + 1), nPages)
newPage.Paste
nPages = nPages + 1
Next
End With

You will probably want to sub-class events for all controls on each page,
including the original page.

Regards,
Peter T
 

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

Top