Results 1 to 3 of 3
  1. #1
    jherbert is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2016
    Posts
    2

    Question Form validation rule based on total in a different table

    Hi All!



    I am creating a form for people to enter allocations of a total that will go into one table, however, the total of the two allocations they enter must equal the total of another query. Below is a mock example of what I am trying to do:

    The form will enter data into "Table 1." Allocation 1 and 2 are different columns in Table 1. Below is the basic layout of Table 1:

    [Table 1]
    |Allocation 1 |Allocation 2|Month |Dept |
    |2 |3 |1/1/16 |100 |

    Now "Query 2" does a total count of employee names based on "Table 2." The total count in Table 2 equals 5. Below is the basic layout of Query 2:

    [Query 2]
    |Total |Month |Dept |
    |5 |1/1/16 |100 |

    I want to put a validation rule into the form so that allocation 1 and 2 equal the total count in Query 2. Does anyone know any way to do this? Any help would be greatly appreciated!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    make a query, "qsAllocationSum", that sums ALL1+ALL2, month, dept

    then when the user enters the value, check it with
    in the text box after update event,

    Code:
    sub txtEnterVal_AfterUpdate
       vSum = Dlookup("[SumOfAllocaton]","qsAllocationSum", "[month]=" & txtMonth & " and "[Dept]='" & cboDept & "'")
      if vSum <> txtEnterVal then
          msgbox "values do not equal"
     endif
    
    end sub

  3. #3
    jherbert is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2016
    Posts
    2
    Thank you for your help! I will give it a try.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Null or unique value - table data validation rule
    By jaworski_m in forum Database Design
    Replies: 3
    Last Post: 07-20-2015, 03:26 AM
  2. Replies: 2
    Last Post: 06-16-2015, 03:52 AM
  3. Replies: 2
    Last Post: 12-27-2013, 07:32 AM
  4. Validation Rule by relating the data with table
    By Falahuddin in forum Access
    Replies: 14
    Last Post: 12-23-2013, 07:15 PM
  5. Validation Rule in Table vs. Form
    By LanieB in forum Forms
    Replies: 2
    Last Post: 03-12-2012, 03:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums