albertc30
Well-known Member
- Joined
- May 7, 2012
- Messages
- 1,091
- Office Version
- 2019
- Platform
- Windows
Hello you all, good people.
It has been a few years last time I have been around.
I have been dwelling with the code bellow and the setfocus function is driving me nuts, as it's not working.
Instead, the cursor is moving to the next field in the form.
What am I doing wrong please?
As always, I am very much appreciated for all of your help.
Many thanks.
Albert
It's good to be back.
It has been a few years last time I have been around.
I have been dwelling with the code bellow and the setfocus function is driving me nuts, as it's not working.
Instead, the cursor is moving to the next field in the form.
What am I doing wrong please?
Code:
Private Sub tbnctel_AfterUpdate()
If Len(Me.tbnctel.Value) < 11 Then
MsgBox "Error! Contact number not long enough."
Me.tbnctel.Value = Left(Me.tbnctel.Value, 11)
tbnctel.Value = "" 'Does clear the correct field.
tbnctel.SetFocus 'Does not set focus on the correct field.
Exit Sub
End If
tbnctel = Format(tbnctel, "00000 000 000")
End Sub
As always, I am very much appreciated for all of your help.
Many thanks.
Albert
It's good to be back.