starmanMike
02-04-2008, 03:34 PM
Hi
I have an error-handler in the lost_focus event of a text box called txtParas. If the figure is out of bounds (in this case 1000 or more) I want the focus put back in this box again. This does happen, but for some reason another calculation (which is written to the next text box called txtMags, and is in that text box's lost_focus event also) gets performed. I only want that calculation performed when the figure in txtParas is acceptable!
This traps the error, and is in txtParas.text_LostFocus:
Select Case theunit
Case "mas"
spcs = Val(txtParas.Text) / 1000
If Val(txtParas.Text) >= 1000 Then
MsgBox (must), vbExclamation, (wrong)
txtParas.SelStart = 0
txtParas.SelLength = Len(txtParas.Text)
txtParas.SetFocus
Exit Sub
End If
...other cases here...
end select
end sub
But even though it breaks out of the sub and shows the message box correctly, the calculation in the next text box is still performed, even though focus is back with txtParas. Why is the other code in txtMags being run, even though its in txtMags' lost_focus event, and we haven't even been there yet?
Help! I know it's got to be something simple...
I have an error-handler in the lost_focus event of a text box called txtParas. If the figure is out of bounds (in this case 1000 or more) I want the focus put back in this box again. This does happen, but for some reason another calculation (which is written to the next text box called txtMags, and is in that text box's lost_focus event also) gets performed. I only want that calculation performed when the figure in txtParas is acceptable!
This traps the error, and is in txtParas.text_LostFocus:
Select Case theunit
Case "mas"
spcs = Val(txtParas.Text) / 1000
If Val(txtParas.Text) >= 1000 Then
MsgBox (must), vbExclamation, (wrong)
txtParas.SelStart = 0
txtParas.SelLength = Len(txtParas.Text)
txtParas.SetFocus
Exit Sub
End If
...other cases here...
end select
end sub
But even though it breaks out of the sub and shows the message box correctly, the calculation in the next text box is still performed, even though focus is back with txtParas. Why is the other code in txtMags being run, even though its in txtMags' lost_focus event, and we haven't even been there yet?
Help! I know it's got to be something simple...