Solved

Access07 - Reliability of a CrossTab Query results in a Form's design.

Posted on 2014-01-26
3
328 Views
Last Modified: 2014-01-27
Hello All

For a particular Form I need the results of a CrossTab query.  That Ctab query will have ItemIDs as its columns and Day's total info as its rows.

Since I've never used CTab queries I wanted to know how reliable they will be in my Form or will it "blow" up if an Item all of a sudden has no info for a day when before it always had info....

EXAMPLE - My Crosstab query is based on this query's code.
SELECT qry_InfoDetails_EndofDay.BusDay, qry_InfoDetails_EndofDay.MachPollPositionID, qry_InfoDetails_EndofDay.AmtIn, qry_InfoDetails_EndofDay.EndofDay
FROM qry_InfoDetailsLastPullDate INNER JOIN qry_InfoDetails_EndofDay ON qry_InfoDetailsLastPullDate.MachPollPositionID = qry_InfoDetails_EndofDay.MachPollPositionID
WHERE (((qry_InfoDetails_EndofDay.BusDay)>=[qry_InfoDetailsLastPullDate].[MaxBusDay]))
GROUP BY qry_InfoDetails_EndofDay.BusDay, qry_InfoDetails_EndofDay.MachPollPositionID, qry_InfoDetails_EndofDay.AmtIn, qry_InfoDetails_EndofDay.EndofDay
ORDER BY qry_InfoDetails_EndofDay.BusDay, qry_InfoDetails_EndofDay.MachPollPositionID;

Open in new window


THEN...My cross tab query will pull info as:
TRANSFORM Sum(qry_LVLInfoDetailEODSinceLastPull.AmtIn) AS SumOfAmtIn
SELECT qry_LVLInfoDetailEODSinceLastPull.BusDay, Sum(qry_LVLInfoDetailEODSinceLastPull.AmtIn) AS [Total Of AmtIn]
FROM qry_LVLInfoDetailEODSinceLastPull
GROUP BY qry_LVLInfoDetailEODSinceLastPull.BusDay
PIVOT qry_LVLInfoDetailEODSinceLastPull.LVLMachPollPositionID;

Open in new window


Since my MachPollPositionID's always will be numbers 1 to 10 but if there is NO EndofDay = True records will it bomb out or is there a way in the first query I can have it put a zero (0) number in every poll position for data=today that would prevent a null query.
0
Comment
Question by:wlwebb
[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
3 Comments
 
LVL 5

Accepted Solution

by:
Lawrence Barnes earned 500 total points
ID: 39810092
Cross tabs are great, but where there's missing data and nothing to create an expected column, the forms do crash.

You can use the NZ function to put in a zero if the value is null on the first query to handle cases of no data.

SELECT qry_InfoDetails_EndofDay.BusDay, qry_InfoDetails_EndofDay.MachPollPositionID, NZ(qry_InfoDetails_EndofDay.AmtIn,0) as AmtIn, qry_InfoDetails_EndofDay.EndofDay

Also, for the columns going on the cross tab results I always wanted the column names (fields displayed in the forms) to have the same names.  So instead of the column name being a date, I changed it to Day-1, Day-2, Day-3 so that the form fields would be stack and the user new that Day-10 was 10 days ago.
0
 

Author Closing Comment

by:wlwebb
ID: 39811949
Thanks for the suggestion.
0
 
LVL 10

Expert Comment

by:Luke Chung
ID: 39812002
Use the IN clause to require column values to avoid problems with missing data.

Here's an example of using a report to display a 12 month report for any date range: http://www.fmsinc.com/MicrosoftAccess/query/crosstab-report/index.html

The same can be done for a form.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

624 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