ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm Setfocus Problem (https://www.excelbanter.com/excel-programming/378386-userform-setfocus-problem.html)

BOBODD

UserForm Setfocus Problem
 
I have several textboxes to collect bank account details. I'm running the
following code on exit:

Private Sub txtBankNum1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(txtBankNum1) < 2 Then
MsgBox "Please enter the two digit bank code."
txtBankNum1.SetFocus
End If
End Sub

Problem is that this doesn't reset the cursor to txtBankNum1, it just moves
on to the next box as normal. Any ideas?

Geoff

UserForm Setfocus Problem
 
Have you tried
Private Sub txtBankNum1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(txtBankNum1) < 2 Then
MsgBox "Please enter the two digit bank code."
Cancel = True
End If
End Sub

hth

Geoff
"BOBODD" wrote:

I have several textboxes to collect bank account details. I'm running the
following code on exit:

Private Sub txtBankNum1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(txtBankNum1) < 2 Then
MsgBox "Please enter the two digit bank code."
txtBankNum1.SetFocus
End If
End Sub

Problem is that this doesn't reset the cursor to txtBankNum1, it just moves
on to the next box as normal. Any ideas?


BOBODD

UserForm Setfocus Problem
 
Cheers, perfect.

"Geoff" wrote:

Have you tried
Private Sub txtBankNum1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(txtBankNum1) < 2 Then
MsgBox "Please enter the two digit bank code."
Cancel = True
End If
End Sub

hth

Geoff
"BOBODD" wrote:

I have several textboxes to collect bank account details. I'm running the
following code on exit:

Private Sub txtBankNum1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(txtBankNum1) < 2 Then
MsgBox "Please enter the two digit bank code."
txtBankNum1.SetFocus
End If
End Sub

Problem is that this doesn't reset the cursor to txtBankNum1, it just moves
on to the next box as normal. Any ideas?



All times are GMT +1. The time now is 02:50 PM.

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