PDA

View Full Version : Text box validation rule on a form


msuserbd
Aug 14, 2009, 04:17 AM
I have 2 fields on a form that if the sum of these 2 fields go over the limit I want to give the user an error message. On the 2nd field I am summing the 2 field together in the validation rule =[Runtime_minutes]+[NoWork_minutes] <>480 , but it doesn't send the error message. I have also tried to add the form to the equation and I get the object doesn't contain the automation object error. What am I doing wrong? I thought it would be a simple addition. Thanks for your help on this.

ScottGem
Aug 14, 2009, 06:03 AM
First, you don't have fields on a form. You have controls that may or may not be bound to fields in a table. This is a subtle but important distinction.

In the After Update event of the 2 text box open the Code Builder to add code like:

If [Runtime_minutes]+[NoWork_minutes] <>480 Then
MsgBox "Can't exceed 480", vbOkOnly
End If

msuserbd
Aug 14, 2009, 07:24 AM
First, you don't have fields on a form. You have controls that may or may not be bound to fields in a table. This is a subtle but important distinction.

In the After Update event of the 2 text box open the Code Builder to add code like:

If [Runtime_minutes]+[NoWork_minutes] <>480 Then
MsgBox "Can't exceed 480", vbOkOnly
End If

Thank you ! It work great, I will call them controls from now on, old habits are hard to break.