Dynamic Multipage Question

apollo169

New Member
Joined
Jun 26, 2010
Messages
1
First off, I would like to thank all of the Excel MVP's in advance for their help. I know that they are all busy and donate a large portion of their time trying to help struggling novice coders, such as myself.

Here's my problem - I use the folowwing code to create a multipage form that dynamically loads a label and a textbox.

Set Mycmd = Me.MultiPage1.Pages("Page1").Controls.Add("Forms.Label.1")
Mycmd.Left = 1
Mycmd.Top = 5 'i + 25
Mycmd.Width = 25
Mycmd.Height = 20
Mycmd.Name = "lblName"
Mycmd.Caption = "Brian"
Mycmd.Visible = True

Set Mycmd1 = Me.MultiPage1.Pages("Page1").Controls.Add("Forms.TextBox.1")
Mycmd1.Left = 35
Mycmd1.Top = 5 'i + 25
Mycmd1.Width = 35
Mycmd1.Height = 20
Mycmd1.Name = "txtName"

In a separate sub procedure I have the following code to complete the addition of the form controls

Private Sub MultiPage1_AddControl(ByVal Index As Long, ByVal Control As MSForms.Control)

End Sub

I can get the form and controls to load just fine, but when I try and retrieve the text that has been entered into the textbox that I have named "txtName", I am given an error. Here's the code I'm using.

ws.Cells(4, 1).Value = Me.txtName.Value

Any ideas???

Thanks again for your help
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,223,734
Messages
6,174,189
Members
452,550
Latest member
southernsquid2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top