Solved

Crosstab query question

Posted on 2014-01-17
3
328 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

771 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

11 Experts available now in Live!

Get 1:1 Help Now