UserForm Setfocus Problem

G

Guest

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?
 
G

Guest

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
 
G

Guest

Cheers, perfect.

Geoff said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top