G
Greg Maxey
Hi,
I am working on a UserForm. I want to enter a number in a
Textbox. If the user enters non-numerical text I want a
message to appear and the focus to return to the text
box. I have the following code set to run on exit from
the text box. I get to the message, but I can't figure
out what I need to return the focus to the textbox that
caused the message.
Private Sub QP_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim oForm As Document
Set oForm = ActiveDocument
oForm.Variables("QP").Value = QP
If Not IsNumeric(QP.Value) Then
MsgBox "You must enter a valid number."
' "What needs to go here to return the focus to the
Textbox OP?"
End If
End Sub
Thank you.
I am working on a UserForm. I want to enter a number in a
Textbox. If the user enters non-numerical text I want a
message to appear and the focus to return to the text
box. I have the following code set to run on exit from
the text box. I get to the message, but I can't figure
out what I need to return the focus to the textbox that
caused the message.
Private Sub QP_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim oForm As Document
Set oForm = ActiveDocument
oForm.Variables("QP").Value = QP
If Not IsNumeric(QP.Value) Then
MsgBox "You must enter a valid number."
' "What needs to go here to return the focus to the
Textbox OP?"
End If
End Sub
Thank you.