Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Crosstab Query on Form

Posted on 2013-06-06
3
Medium Priority
?
491 Views
Last Modified: 2013-06-06
I need to find another option since I cannot put a crosstab query on my form. I need to show usage by item with the month/year as the column headings. I could use the ColumnHeading properties in the crosstab query but then I would have to keep adding new months to it as the year goes on. Is there any easier way to do this? If so, any ideas you care to share?
0
Comment
Question by:Lawrence Salvucci
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Expert Comment

by:Dale Fye
ID: 39225266
Yes, you can force the Crosstab to  display columns that don't actually exist in your query using the PIVOT clause.  The last element of the Crosstab query looks something like:

PIVOT yourTable.yourField

You can modify that to something like:

PIVOT yourTable.yourField IN ("JAN/2013", "FEB/2013", "MAR/2013", ...)

Make sure that the spelling of the spellings in the IN ( ) clause are accurate because only those values that show up in the IN clause will be displayed.  And even if a value is not in your query results, that column will be displayed.
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 39225288
I'm not sure I follow you 100%. Here is the SQL for my crosstab. How would it use my date field to show the month/year and increment as the year goes on?



PARAMETERS [Forms]![frmPurchasingAnalysis1]![cbofpartno] Text ( 255 );
TRANSFORM Sum(qryPOHistory.fqtyrecv) AS SumOffqtyrecv
SELECT qryPOHistory.fpartno, Sum(qryPOHistory.fqtyrecv) AS [Total Of fqtyrecv]
FROM qryPOHistory
WHERE (((qryPOHistory.fpartno)=[Forms]![frmPurchasingAnalysis1]![cbofpartno]))
GROUP BY qryPOHistory.fpartno
PIVOT qryPOHistory.[Month/Year];

Open in new window

0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 39227062
I'm not certain how your [Month/Year] field is formatted, what do those values look like.

Lets assume it is: mmm/yy

If that is the case, you could use:

PIVOT qryPOHistory.[Month/Year] IN ("Jan/13", "Feb/13", "Mar/13", "Apr/13", "May/13", "Jun/13", "Jul/13", "Aug/13", "Sep/13", "Oct/13", "Nov/13", "Dec/13")

This would give you all of the months for 2013.  If, however, your [Month/Year] column contains more than a single year, then you might have to write some code, to determine all of the [Month/Year] combinations and build that IN ( ) clause and append it to the end of your query.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

618 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