Results 1 to 3 of 3
  1. #1
    Bkper087 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Posts
    81

    Sum If Type Function in Access

    I saw a number of topics that were related via the search, but am still a little lost. I am trying to create the equivalent of a SumIf function in Excel. I am creating a hiring and salary management database for a summer camp. I have a weekly salary field and a series of Yes/No check boxes that are related to the weeks staff members will be available. I want to write an expression that says if the week 1 field = "Y", and the week 2 field = "Y", but the week 3 field = "N" then multiply the salary by 2 based on the 2 weeks of availability. I have tried using DSum, but I am running into the parameter value error. I'm not sure why, it is probably unrelated. Anyway, I was just curious if that was the best option or if I should be using a different function.



    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If they are truly Yes/No type fields then ="Y" or ="N" will fail. Yes/No field is Boolean type. Values are -1/0. Can use those or constants True/False without quote marks or not even use =. The syntax for IIf is:

    IIf(expression, do this if expression true, do this if expression false)

    So try:

    Sum([Salary] * IIf(week1 AND week2 AND NOT week3, 2, 1))

    or consider:

    Sum([Salary] * IIf(week1,1,0) + IIf(week2,1,0) + IIf(week3,1,0))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Bkper087 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Posts
    81
    Thanks for the reply. I wound up using something very similar. I used an IIF statement for each week and then added the those results in a separate column.

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

Similar Threads

  1. Edit/Update function data type mismatch
    By gaker10 in forum Forms
    Replies: 11
    Last Post: 07-09-2014, 02:41 PM
  2. Unbound text box data type and "Delete" function
    By gaker10 in forum Programming
    Replies: 16
    Last Post: 06-13-2014, 10:46 AM
  3. Replies: 1
    Last Post: 08-28-2013, 06:11 AM
  4. Replies: 1
    Last Post: 07-19-2013, 12:00 PM
  5. Replicating a switchboard-type function
    By roaftech in forum Forms
    Replies: 3
    Last Post: 03-06-2013, 12:26 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