Results 1 to 7 of 7
  1. #1
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102

    Sum of certain outputs in a continuous form

    I have an endless form which refers to a query.
    I would like to have the total for the holidays. But there are different reasons for absence. That is, it should display in a text field how many days the reason for absence was "holidays". This should be displayed in a text field in this continuous form.$
    Click image for larger version. 

Name:	Screenshot 2023-06-07 224012.png 
Views:	15 
Size:	5.7 KB 
ID:	50330
    Abwesenheitsgrund = reasons for absence
    Abwesenheit_in_Tagen = absence in days

    I tried it like this:
    =Summe(Nz([Abwesenheit_in_Tagen]))
    but then every absence is added
    It should be 6, but it outputs 9.

    How should i do that?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Use an aggregate query

    Group by Abwesenheitsgrund
    Sum Abwesenheit_in_Tagen

  3. #3
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by CJ_London View Post
    Use an aggregate query

    Group by Abwesenheitsgrund
    Sum Abwesenheit_in_Tagen
    But the query is not just these 2 columns. There are more, so it doesnt work with a aggregate query.
    The query consists of 3 different tables.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Create a new query based on your query for the aggregates

  5. #5
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by CJ_London View Post
    Create a new query based on your query for the aggregates
    I dont really understand how that works, but is there no way doing that in the form itself?

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    if you just want holidays you could use the dsum function

    =Dsum("Abwesenheit_in_Tagen","myQuery","Abwesenheitsgrund='Ferien'")

    replace myQuery with the name of the recordsource for your form

    or perhaps try

    =Summe(iif([Abwesenheitsgrund]="Ferien",[Abwesenheit_in_Tagen],0))

    or maybe

    =-Summe([Abwesenheit_in_Tagen]*[Abwesenheitsgrund]="Ferien")



  7. #7
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by CJ_London View Post
    if you just want holidays you could use the dsum function

    =Dsum("Abwesenheit_in_Tagen","myQuery","Abwesenheitsgrund='Ferien'")

    replace myQuery with the name of the recordsource for your form

    or perhaps try

    =Summe(iif([Abwesenheitsgrund]="Ferien",[Abwesenheit_in_Tagen],0))

    or maybe

    =-Summe([Abwesenheit_in_Tagen]*[Abwesenheitsgrund]="Ferien")


    Thank you very much it worked with the Dsum function.

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

Similar Threads

  1. Replies: 5
    Last Post: 01-06-2022, 05:55 AM
  2. 2 buttons 2 outputs with 1 report
    By Thompyt in forum Programming
    Replies: 3
    Last Post: 11-02-2017, 03:31 PM
  3. Replies: 4
    Last Post: 08-05-2015, 02:08 PM
  4. Query outputs duplicates from 1 table
    By Govman in forum Queries
    Replies: 1
    Last Post: 02-16-2015, 06:01 PM
  5. Combox Box Outputs the ID in text
    By Alexandre Cote in forum Queries
    Replies: 3
    Last Post: 07-20-2010, 08:47 AM

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