inncoggnitto
Programmer
i have a form with numerous text boxes. i am validating data on lost focus. i want to return the user back to the box if the data is not valid (i.e., an out of range number). i don't want to use keep focus since a blank might be a valid input. for example on the LostFocus for a text box
does not set the focus back to the text box. the cursor still moves to the next box. i have tried setting focus to any other control and still it does not work, just moves to the next control in the tab order.
suggestions are welcomed.
Code:
Private Sub txtLongDecimal_LostFocus()
If txtLongDecimal.Text <> "" And IsNumeric(txtLongDecimal.Text) = True Then
If txtLongDecimal.Text > 92 And txtLongDecimal < 107 Then
txtLongDecimal.Text = Round(txtLongDecimal.Text, 5)
txtLongDecimal.SetFocus
Else
MsgBox "This value must be >= 93 and <= 106 degrees."
txtLongDecimal.Text = ""
txtLongDecimal.SetFocus
End If
ElseIf txtLongDecimal.Text <> "" And IsNumeric(txtLongDecimal.Text) = False Then
MsgBox "This value must be numeric and must be >= 93 and <= 106 degrees."
txtLongDecimal.Text = ""
txtLongDecimal.SetFocus
Else
txtLongDecimal.Text = ""
txtLongDecimal.SetFocus
End If
End Sub
does not set the focus back to the text box. the cursor still moves to the next box. i have tried setting focus to any other control and still it does not work, just moves to the next control in the tab order.
suggestions are welcomed.