Setting Focus not working as expected
Thanks for the reply.
Here is the new complete code. Right now the cursor still moves to the next
field.
Private Sub TXBBasisPoints_AfterUpdate()
'Dim msgstring As TextBox
'Dim formatTXBasisPoints As Variant
intMax = Range("MaxLoan_Spread")
intMin = Range("MinLoan_Spread")
intValue = Range("Loan_Spread")
intDefault = Range("DLoan_Spread")
strMessage = "Enter a loan spread between " & intMin & " and " & intMax
& " basis points."
blnNumeric = IsNumeric(Me.TXBBasisPoints)
If blnNumeric Then
'value is numeric
MsgBox ("Hello")
'value is not numeric
Else
MsgBox ("Value is not numeric. Please enter a number")
Cancel = True
Me.TXBBasisPoints.SetFocus
End If
End Sub
If I rem out these two lines in the FALSE condition
Cancel = True
Me.TXBBasisPoints.SetFocus
and then include this:
Private Sub TXBBasisPoints_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = True
Me.TXBBasisPoints.SetFocus
End Sub
That WILL leave the focus on the current control BUT I can never leave that
control as the Exit even returns the focus to the control.
I know I'm missing something obvious.
|