Results 1 to 9 of 9
  1. #1
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118

    DSum with a paramter query


    I have a report that is based on a parameter query. The parameter I am prompted to change is CurrYear when I run the report. There is no other criteria in the query.
    The query is called "SelectYearQry", and the field I want to sum is CSRHours. Both of the following syntax produce errors when I try to sum the CSRHours field. =Sum([CSRHours]) or =DSum("[CSRHours]","SelectYearQry"). Both syntax work fine in a select query but not in a parameter query. Any help would be appreciated. Unable to post a copy of the database

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Post the entire SQL statement.

    Maybe could apply filter to report instead of parameterizing query. I don't use dynamic parameter query.

    Could also use report Sorting & Grouping features with aggregate calcs in textbox. This would allow display of detail data as well as summary calcs.
    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
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118
    I was able to provide a condensed DB with all the relevant fields. To clarify, I want to sum a field on a report that uses a parameter query. The field to sum is "CSRHours" and the report is the YearSelectRpt".
    DB attached
    Attached Files Attached Files

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Is this what you're after:
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    @JohnathanT; why are the hours from the query formatted as currency in the report??
    EDIT - I mean in the CSRHours textbox:

    $#,##0.00;($#,##0.00)
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118
    It is exactly what I'm looking for but I don't see the field "TotalHrs" anywhere in the database. I'd like to sum other fields but I can't see how this one works so I can replicate it.

  7. #7
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118
    Micron, Just something I missed. Will correct it

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by JonathanT View Post
    It is exactly what I'm looking for but I don't see the field "TotalHrs" anywhere in the database. I'd like to sum other fields but I can't see how this one works so I can replicate it.
    The control called TotalHrs is in the reports Footer Section but is hidden, so you will need to view the report in design view to see it.
    EDIT:
    BTW you only have fields in tables and queries. In forms and reports you have "Controls" e.g. textboxes, comboboxes which are bound to fields in the table/query that is used as the Record Source of the Form/Report
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118
    Thanks, Bob Works Great

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

Similar Threads

  1. Enter Paramter Value Box
    By lhanley22 in forum Queries
    Replies: 3
    Last Post: 07-21-2021, 02:17 PM
  2. Paramter & Form Problems
    By Korei Khan in forum Database Design
    Replies: 3
    Last Post: 10-24-2015, 10:44 AM
  3. Dynamic Date Paramter Change?
    By aellistechsupport in forum Queries
    Replies: 27
    Last Post: 08-27-2015, 01:21 PM
  4. Replies: 3
    Last Post: 03-05-2015, 04:15 PM
  5. Replies: 3
    Last Post: 10-22-2014, 02:38 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