me.facecheck.setfocus - it gave an error
facecheck.setfocus - didn't do anything.
Code
Sub txbFaceAmt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call FaceLimitCheck(txbFaceAmt)
End Sub
Sub FaceLimitCheck(Facecheck)
If Not (Facecheck = vbNullString) Then
If Not (IsNumeric(Facecheck)) Then
MsgBox ("Invalid entry please use numbers")
Facecheck.Value = ""
Facecheck.SetFocus
Else
If Facecheck < 25000 Then
MsgBox ("Minimum face amount is 25,000")
Facecheck.Value = ""
Else
Facecheck.Value = Format(Facecheck, "$ #,##0,000")
End If
End If
End If
Call CheckTotalFace
End Sub
I thought you wanted to set the focus to txbfaceamt?
======
But even simpler would be to change that FaceLimitCheck into a Function that
returns a boolean--if it's ok, then return true
Then you could use:
Sub txbFaceAmt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
dim OkToLeave as boolean
oktoleave = FaceLimitCheck(txbFaceAmt)
if oktoleave = true then
'do nothing
else
cancel = true 'don't leave txbfaceamt
end if
End Sub
This:
if oktoleave = true then
'do nothing
else
cancel = true 'don't leave txbfaceamt
end if
Can be replace with a single line:
cancel = (not oktoleave)
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.