Results 1 to 5 of 5
  1. #1
    cheloto is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    7

    Access code - various years

    I want to place a result with this attempt:

    =Abs(sum(Month([Salgsdato]=8 and (Year([Salgsdato]=([Startår]-1))

    Dateformat is dd.mm.yyyy

    Unforunately something is wrong
    Appreciate if someone can tell me how to correct it.

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    That expression makes no sense. What field do you want to Sum?

    "Something is wrong" doesn't tell us much. What is error message?
    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
    cheloto is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    7
    Quote Originally Posted by June7 View Post
    That expression makes no sense. What field do you want to Sum?

    "Something is wrong" doesn't tell us much. What is error message?
    From a spesific table I have various values in the field «salgsdato» all values only with the month 8 and year spesific f.eks. 2018 shall be added.
    did you understand?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Still did not specify which field needs to be summed. You only show the conditional criteria.

    =Sum(IIf(Month([Salgsdato])=8 And Year([Salgsdato])=[Startår]-1, fieldname, 0))

    Or do you really want to count how many records meet the criteria?

    =Sum(IIf(Month([Salgsdato])=8 And Year([Salgsdato])=[Startår]-1, 1, 0))

    or

    =Count(IIf(Month([Salgsdato])=8 And Year([Salgsdato])=[Startår]-1, 1, Null))
    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.

  5. #5
    cheloto is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    7
    Thank you so much - the error was only one parantes ahead of Year . Now everything is working good.

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

Similar Threads

  1. Replies: 19
    Last Post: 02-23-2018, 02:44 PM
  2. Replies: 6
    Last Post: 09-21-2015, 12:36 PM
  3. Replies: 3
    Last Post: 05-20-2014, 05:43 PM
  4. Code to list 3 years record
    By buster497 in forum Access
    Replies: 5
    Last Post: 03-01-2014, 02:35 PM
  5. Sigh, having used Access in 5 years and stuck..
    By Access Denied in forum Access
    Replies: 3
    Last Post: 10-06-2009, 02:19 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