ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Forcing the cursor (https://www.excelbanter.com/excel-programming/361992-forcing-cursor.html)

B Wassen

Forcing the cursor
 
Hello,

In a form I like to force the cursor to start in textbox1 because when I
open the form now it starts with the cursor in textbox2.

Private Sub CommandButton3_Click()

On Error Resume Next
FormWijzigen TextBox1.SetFocus
With Sheets("Data").Range("B:B").Find(TextBox1.Value,
LookIn:=xlValues)

TextBox2.Value = .Offset(0, -1).Value
TextBox3.Value = .Offset(0, 1).Value
TextBox4.Value = .Offset(0, 0).Value
TextBox5.Value = .Offset(0, 2).Value
TextBox6.Value = .Offset(0, 3).Value
TextBox7.Value = .Offset(0, 4).Value
TextBox8.Value = .Offset(0, 5).Value
TextBox9.Value = .Offset(0, 6).Value
TextBox10.Value = .Offset(0, 7).Value
End With
End Sub

Ben



Tom Ogilvy

Forcing the cursor
 
Userform?

change the tabindex property to zero for Textbox1.

--
Regards,
Tom Ogilvy



"B Wassen" wrote in message
...
Hello,

In a form I like to force the cursor to start in textbox1 because when I
open the form now it starts with the cursor in textbox2.

Private Sub CommandButton3_Click()

On Error Resume Next
FormWijzigen TextBox1.SetFocus
With Sheets("Data").Range("B:B").Find(TextBox1.Value,
LookIn:=xlValues)

TextBox2.Value = .Offset(0, -1).Value
TextBox3.Value = .Offset(0, 1).Value
TextBox4.Value = .Offset(0, 0).Value
TextBox5.Value = .Offset(0, 2).Value
TextBox6.Value = .Offset(0, 3).Value
TextBox7.Value = .Offset(0, 4).Value
TextBox8.Value = .Offset(0, 5).Value
TextBox9.Value = .Offset(0, 6).Value
TextBox10.Value = .Offset(0, 7).Value
End With
End Sub

Ben





B Wassen

Forcing the cursor
 
Tom,

thank you, is the right solution.

Regards,

Ben




All times are GMT +1. The time now is 07:35 PM.

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