ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Click event for UserForm Multipage (https://www.excelbanter.com/excel-programming/444535-click-event-userform-multipage.html)

Steve[_4_]

Click event for UserForm Multipage
 
Hi everyone. I have a User Form Multipage with 2 tabs on it. I need the focus to be set on the first tab upon initialization. On the second tab I have a text box. I am trying to create a click event that when the user clicks tab 2, the default field in the text box becomes highlighted so the user can simply type over without deleting the default value.
The code I have is as follows:

Private Sub MultiPage1_Click(1)
With UserForm1.TextBox1
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub

But I get a Compile error, expected identifier. Any thoughts?

Thanks!

GS[_2_]

Click event for UserForm Multipage
 
Try...

Private Sub MultiPage1_Click(ByVal Index As Long)
If Index = 1 Then '//Page2 (Index is zero based)
With Me.TextBox1
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
End If
End Sub

Private Sub UserForm_Initialize()
Me.MultiPage1.Value = 0 '//set to Page1
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




All times are GMT +1. The time now is 09:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com