Jim,
Thanks again.
I got an invalid use of ME error & modified code. The textbox is on the
firstpage of a 2 page muultipage on top of a userform.
With UserForm1.MultiPage1
'Make the second page active
..Value = 0
..Pages(0).Text1.SetFocus
End With
I'm guessing that 0 is the index of the first page as I had error 438 (obj
does not supp..)when .value was 1 and error 2110 with .pages(1)
I dont get errors with code shown but dont get focus in textbox either.
What is weird is when I use Tab key - the focus goes to textbox2 which is the
next tab order.
Martin
--
Martin
"Jim Cone" wrote:
> Martin,
>
> If the textbox is on one of the pages (not directly on the userform)
> then code something like this could be used...
>
> Private Sub UserForm_Activate()
> With Me.MultiPage1
> 'Make the second page active
> .Value = 1
> .Pages(1).TextBox4.SetFocus
> End With
> End Sub
> '----------------------------
> Jim Cone
>
>
>
>
> "Martin" <Martin@discussions.microsoft.com>
> wrote in message
> news:29E69840-38E3-4706-A3CA-A3CDF9E20803@microsoft.com
> Jim,
> Thank you for your comments. Text1 has a tabindex of 0. I've made the other
> changes uou indicated but Text1 still does not receive the focus.
> When I just had the items on a userform Text1 would receive focus. The
> problem developed when I went to MultiPage. Any thoughts?
> Martin
>
>
>
> "Jim Cone" wrote:
> > Martin,
> > Set the tab order so that Text1 is first in the tab order.
> > That control gets the focus when the form is shown.
> > The Load UserForm1 line is not necessary as the form
> > loads when you first refer to the form.>
> > Also, control settings code should come before the form is shown.>
> > Regards,
> > Jim Cone
> > San Francisco, USA
> > http://www.realezsites.com/bus/primitivesoftware
>
>
> >
> >
> > "Martin" <Martin@discussions.microsoft.com>
> > wrote in message
> > news:5170A04F-DBAD-4444-AFB9-A69026B99E03@microsoft.com...
> > Userform1 has a multipage with two pages.
> >
> > Page1 has 8 textboxes - Text1 through Text8 and 3 comboboxes
> >
> > I would like Text1 to receive focus so data can be entered. My code worked
> > fine on a regular userform but when I changed to a multipage Text1 does not
> > receive focus - I am stumped. Appreciate any help.
> > here is code to load
> > Sub show_myform()
> > Worksheets("Constants").Range("mysounds").Value = 2
> > UserForm1.ComboBox1.AddItem "Hourly"
> > UserForm1.ComboBox1.AddItem "Milage"
> > UserForm1.ComboBox1.ListIndex = 0
> > UserForm1.ComboBox2.AddItem "On"
> > UserForm1.ComboBox2.AddItem "Off"
> > UserForm1.ComboBox2.ListIndex = 1
> > Load UserForm1
> >
> > On Error Resume Next
> > UserForm1.Show vbModeless
> > 'UserForm1.ComboBox2.ListIndex = 1
> >
> > With UserForm1.Text1
> > .SetFocus
> > .SelStart = 0
> > .SelLength = Len(.Text)
> > Cancel = True
> > End With
> >
> > End Sub
> > --
> > Martin
> >
>
Bookmarks