Solved

Crosstab query question

Posted on 2014-01-17
3
331 Views
Last Modified: 2014-01-18
I have created a crosstab query which work fine and displays all records.  But in the query designer I want to set a criteria using a year number (like 2013) which I'm getting from a form combobox.

Here is the query criteria:

[Forms]![frmSelectYearForMonthlySumReports]![cboYear]

But it doesn't work because that field on the query is:

Format([DateWorked],"mmm")

What do I have to change in the criteria line?

--Steve
0
Comment
Question by:SteveL13
  • 2
3 Comments
 
LVL 34

Expert Comment

by:PatHartman
ID: 39789433
You can't use this field since it has already been formatted to be a month name.  Open the query in SQL View and add this to the WHERE clause -

Where ....
AND [Forms]![frmSelectYearForMonthlySumReports]![cboYear] = Year([DateWorked]);

There is no need to add the additional column to the select clause.
0
 

Author Comment

by:SteveL13
ID: 39789486
There is no where clause to add this to.  Here is the SQL:

TRANSFORM Sum(qryMonthlySumReportPublicHrs.TotPublicHours) AS SumOfTotPublicHours
SELECT qryMonthlySumReportPublicHrs.DocentID, qryMonthlySumReportPublicHrs.LastName, qryMonthlySumReportPublicHrs.FirstName, tblDocents.AssignedDay, Sum(qryMonthlySumReportPublicHrs.TotPublicHours) AS [Total Of TotPublicHours]
FROM qryMonthlySumReportPublicHrs LEFT JOIN tblDocents ON qryMonthlySumReportPublicHrs.DocentID = tblDocents.DocentID
GROUP BY qryMonthlySumReportPublicHrs.DocentID, qryMonthlySumReportPublicHrs.LastName, qryMonthlySumReportPublicHrs.FirstName, tblDocents.AssignedDay
PIVOT Format([DateWorked],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
0
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 39789699
So add one.


TRANSFORM Sum(qryMonthlySumReportPublicHrs.TotPublicHours) AS SumOfTotPublicHours
SELECT qryMonthlySumReportPublicHrs.DocentID, qryMonthlySumReportPublicHrs.LastName, qryMonthlySumReportPublicHrs.FirstName, tblDocents.AssignedDay, Sum(qryMonthlySumReportPublicHrs.TotPublicHours) AS [Total Of TotPublicHours]
FROM qryMonthlySumReportPublicHrs LEFT JOIN tblDocents ON qryMonthlySumReportPublicHrs.DocentID = tblDocents.DocentID
Where [Forms]![frmSelectYearForMonthlySumReports]![cboYear] = Year([DateWorked])
GROUP BY qryMonthlySumReportPublicHrs.DocentID, qryMonthlySumReportPublicHrs.LastName, qryMonthlySumReportPublicHrs.FirstName, tblDocents.AssignedDay
PIVOT Format([DateWorked],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now