Results 1 to 7 of 7
  1. #1
    Af7082a is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2018
    Posts
    4

    Wanting a Query to Total the Number of Specific Issues Per Month

    I used this first code to get the total number of issues per month based upon the reporting date



    SELECT Count([Employee Complaints Database].[Reporting Date]) AS [CountOfReporting Date]
    FROM [Employee Complaints Database]
    HAVING ((Year([Reporting Date])=Year(Now()) And Month([Reporting Date])=Month(Now())));

    This gave me a total and worked fine.

    Now I'm trying to get specific with the number of issue types per month and I'm having a syntax error.
    Could anyone help?

    This is the second code tried:

    SELECT Count([Employee Complaints Database].[Issue Type]), AS Occurrences
    FROM [Employee Complaints Database]
    HAVING ((Year([Reporting Date])=Year(Now()) And Month([Reporting Date])=Month(Now())))
    GROUP BY [Employee Complaints Database].[Issue Type];

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you need to add the month in the query fields,
    (no comma before AS OCCURRENCES)
    And Id think youd want a data range to limit the data.

    SELECT Count([Employee Complaints Database].[Issue Type]) AS Occurrences
    format([reporting date],"yyyy-mm") as RptMonth
    FROM [Employee Complaints Database]
    where [
    reporting date] between forms!myForm!StartDate and forms!myForm!EndDate





  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Just an FYI: you should delete ALL SPACES in object names.
    You have a field name "[Reporting Date]"
    and a table name "[Employee Complaints Database]"

    Better is
    "[ReportingDate]" or "[Reporting_Date]"
    "[EmployeeComplaintsDatabase]" or "[Employee_Complaints_Database]"


    Object names mean fields names, table names, form names, query names report names and module names.



    Also, please use code tags when posting code/SQL.
    You posted
    SELECT Count([Employee Complaints Database].[Reporting Date]) AS [CountOfReporting Date]
    FROM [Employee Complaints Database]
    HAVING ((Year([Reporting Date])=Year(Now()) And Month([Reporting Date])=Month(Now())));


    Should be (easier to read and it keeps formatting) :
    Code:
    SELECT Count([Employee Complaints Database].[Reporting Date]) AS [CountOfReporting Date]
    FROM [Employee Complaints Database]
    HAVING ((Year([Reporting Date])=Year(Now()) And Month([Reporting Date])=Month(Now())));

    Paste in the code, highlight it and press the "#" in the menu.

  4. #4
    Af7082a is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2018
    Posts
    4

    New Issue

    Hi Thank you! I got it to work. But now I'm trying to print a report that contains three sub reports and it keeps printing the sub reports twice in print mode, but it shows normal in the report mode. Any idea on what might be causing this?


    Object names mean fields names, table names, form names, query names report names and module names.



    Also, please use code tags when posting code/SQL.
    You posted
    SELECT Count([Employee Complaints Database].[Reporting Date]) AS [CountOfReporting Date]
    FROM [Employee Complaints Database]
    HAVING ((Year([Reporting Date])=Year(Now()) And Month([Reporting Date])=Month(Now())));


    Should be (easier to read and it keeps formatting) :
    Code:
    SELECT Count([Employee Complaints Database].[Reporting Date]) AS [CountOfReporting Date]
    FROM [Employee Complaints Database]
    HAVING ((Year([Reporting Date])=Year(Now()) And Month([Reporting Date])=Month(Now())));

    Paste in the code, highlight it and press the "#" in the menu.[/QUOTE]

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,918
    The subreports are in Detail section? Main report is bound? How many records does the main report retrieve?
    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.

  6. #6
    Af7082a is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2018
    Posts
    4
    Quote Originally Posted by June7 View Post
    The subreports are in Detail section? Main report is bound? How many records does the main report retrieve?

    The Sub Reports are in the detail section. I'm not sure if the main report is bound. And the main report is not receiving records but instead receiving averages and totals.

    Thank you!

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,918
    Does the main report have a RecordSource? If it does, then it is bound.

    Subreports will repeat for each record in the main report.
    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.

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

Similar Threads

  1. How to total by each specific project number?
    By newuserthatneedsassistanc in forum Queries
    Replies: 18
    Last Post: 07-19-2017, 02:44 PM
  2. Replies: 34
    Last Post: 03-03-2014, 09:24 AM
  3. Replies: 1
    Last Post: 01-24-2013, 05:50 PM
  4. How to get a specific number for the current month?
    By Ronald Mcdonald in forum Access
    Replies: 1
    Last Post: 06-14-2012, 11:55 AM
  5. Query for specific month
    By bespra in forum Queries
    Replies: 5
    Last Post: 10-22-2011, 07:18 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