PDA

Click to See Complete Forum and Search --> : Run Time Error


hbarker
Nov 2nd, 1999, 07:54 PM
i am using a lostfocus()routine that checks to see if a field contains the correct information. If it does not I set focus back to that text box then I display a message box. The app works before I make it an executable, however, when I run it as an executable I receive a run time error 5 every time I lose focus with incorrect information. Before it displays the message box it gives me the error then displays the message box then upon clicking ok the app shuts down. The following is the code:

Private Sub startonpeak_LostFocus()
If Not IsNumeric(startonpeak.Text) Then
startonpeak.SetFocus
MsgBox "Please enter the start on peak reading for channel 1.", vbOKOnly

Else
startonpeak.BackColor = vbWhite
End If

End Sub

Any ideas?

mcleran
Nov 2nd, 1999, 07:59 PM
Use the Validate event instead of the LostFocus event. Make sure that the Causes Validation property of your controls is set to True. This will allow you to cancel the moving of focus by setting Cancel=True.

hbarker
Nov 2nd, 1999, 08:00 PM
Could you explain this a little further?