View Full Version : Message Box will not come up on wrong value


819 Ag
04-02-2002, 08:34 AM
Friends,

I have an unbound text box on my form. The default value is 0 and there are two buttons that are associated with this text box. One button increments the value of the text box 1,2,3... (this is done with a macro on the OnClick event) and the other decrements the value of the text box 5,4,3,2...(also a macro on the OnClick event).

The problem I am having with the text box is error checking. I want a message box to appear when the text box goes to a negative number -1,-2,-3, etc. Where do I put the code to make this happen?

Here is what I have and it does not work.

Private Sub Text71_Exit(Cancel As Integer)

Dim strMsg As String
strMsg = "The value you entered is not valid"

If [Text71] < 0 Then
MsgBox strMsg

End If
End Sub

Any suggestions?

Rich
04-02-2002, 09:20 AM
Use the before update event
If Me.Text21 <0 Then
Beep
Me.Undo
MsgBox "The value you entered is not valid"
End If