Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Access (https://www.askmehelpdesk.com/forumdisplay.php?f=441)
-   -   Text box validation rule on a form (https://www.askmehelpdesk.com/showthread.php?t=386745)

  • Aug 14, 2009, 04:17 AM
    msuserbd
    text box validation rule on a form
    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.
  • Aug 14, 2009, 06:03 AM
    ScottGem

    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
  • Aug 14, 2009, 07:24 AM
    msuserbd
    Quote:

    Originally Posted by ScottGem View Post
    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.

  • All times are GMT -7. The time now is 09:17 AM.