473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Crosstab Query Not Functioning With Report

68
Go day all,

I’ve a problem with a report that is based on the crosstab query below.

The purpose of this query is to show the listed below items for all the courses plus to break down the status showing its total individually :

1-Session ID
2-Course Title
3-Course Type
4-Start Date
5-End Date
6-Location
7-Seats
8-Available Seats
9-Status ( In-Progress, Complete, Cancel and No show).

Here is the problem:

When I open up the query itself, it works fine; it shows the following:

(1)-7 (2)-Fire Course (3)-In-House (4)-11/11/2010 (5)-11/15/2010 (6)-London (7)-20 (8)-19 (9)-1 *

•The total of the enrolled employees who have In-Progress status is 1.

However, when I go to the report itself I got an error message saying “the Ms access database engine does not recognize "Cancel" as a valid name or expression.

My query:

Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Count(enrollment.[Employee ID]) AS [CountOfEmployee ID]
  2. SELECT Sessions.[Session ID], Courses.[Course Title], Courses.[Course Type], Sessions.[Start Date], Sessions.Location, Sessions.Seats, Sessions.AvailableSeats, Sessions.[End Date]
  3. FROM Courses INNER JOIN (Sessions INNER JOIN enrollment ON Sessions.[Session ID]=enrollment.[Session ID]) ON Courses.[Course ID]=Sessions.[Course ID]
  4. GROUP BY Sessions.[Session ID], Courses.[Course Title], Courses.[Course Type], Sessions.[Start Date], Sessions.Location, Sessions.Seats, Sessions.AvailableSeats, Sessions.[End Date]
  5. PIVOT enrollment.Status;
  6.  
I’d greatly appreciate any feedback to overcome this problme ?
May 17 '10 #1
4 2665
TheSmileyCoder
2,322 Expert Mod 2GB
I haven't seen this issue myself, and have not really used crosstab queries in Access, so im not sure if this will solve your issues, but your problem might be related to the fact that Cancel is a reserved word in Access.

Should be fairly easy to test though, just replace Cancel with Cancelled and see if that works. Also make sure you have no textboxes (or similar controls) in your report named Cancel.
May 17 '10 #2
ahd2008
68
Thanks Sir for your feedback; maybe my explanation wasn’t that sufficient let me go more in depth

As per I mentioned, so far the crosstab query only shows this record( the only record there) :

(1)-7 (2)-Fire Course (3)-In-House (4)-11/11/2010 (5)-11/15/2010 (6)-London (7)-20 (8)-19 (9)-1 *

•The total of the enrolled employees who have In-Progress status is 1.

I’ve tried several attempts to overcome this problem by adding new records that has all the possible enrollment status, and it did work. The error message that I got with report as mentioned before says “the Ms access database engine does not recognize "Cancel" as a valid name or expression”; so what I did is that I added new record that has Cancel status. In the case the crosstab query will show:

(1)-7 (2)-Fire Course (3)-In-House (4)-11/11/2010 (5)-11/15/2010 (6)-London (7)-20 (8)-19 (9)-1 * (10)-1**

•The total of the enrolled employees who have In-Progress status is 1.
** the total of the enrolled employees who have Cancel status is 1.

Now, when I open the report I get the same error message but instead of the word Cancel I get Complete. To overcome this problem I entered two more records that have the remaining enrollment status No show & Complete. After all this, it works fine with me now.

However, why this error message pops up when there is no record or when I don’t assign all the possible enrollment status to the records?

From what I can tell, the report should return 0 in case there is no records in the report fields (Cancel, No Show, Complete,In-Progress) or even if not all the entered records has all the possible enrollment status.

I’d appreciate any suggestion to solve this problem.
May 18 '10 #3
Stewart Ross
2,545 Expert Mod 2GB
Hello. Basing a report on a crosstab query can cause problems as reports need to refer to fixed field names. When you execute a crosstab which results in a pivoted status field like your count of Cancels or No-Shows, the number of field headings returned by the pivot expression reflects the number of different status values in the records aggregated. If your records have only two different status values - Cancel and Completed as you said - then there will be no fields in the resulting crosstab headed with the other values - No Show or In Progress.

In other words, if there are only two of the four possible status values present in your records then two fields expected in your report will be missing from the result of running the report's crosstab recordsource query. The report fails because of these missing fields - which is why you are finding that the report works OK if you enter all possible status values but otherwise errors out.

To resolve this you will need to specify the column headings for the pivot field in your crosstab query. In query design view, right-click on the Column Heading field and select Properties. In the Column Headings property type all possible status values, separated by commas, like this:

"Cancel", "No Show", "Complete", "In-Progress"

If you run the crosstab query after doing so you will see that the number of column headings will reflect the headings you have provided and will not vary if you have no records of one or more of these status values.

Please note two crucial points that arise: firstly, the column headings MUST match the exact spelling of the value pivoted ("In-Progress" is not the same as "In Progress", for example). Second, if you add new status values at a later date you MUST update the manually-set crosstab headings, as records with the new status values will not be aggregated in your crosstab query at all if the manual headings do not match the actual values in your records.

-Stewart
May 18 '10 #4
ahd2008
68
Stewart Ross,

You are right;I'm sure that i didn't address my problme properly which led to this confusion. Anyhow, I did what you told me and it is okay now

Thank you for your glorious efforts and TheSmileyOne as well.
May 21 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Tom | last post by:
I have a report based on a crosstab query that shows monthly automobile sales. The report is grouped on Make so that it shows the models under each Make. I want to now get the subtotals by Make and...
8
by: Donna Sabol | last post by:
First, I should start by saying I am creating a database to be used by some very impatient, non-computer literate people. It needs to be seameless in it's operation from their point of view. I...
4
by: No Spam | last post by:
Dear Access 2000 users, I have a crosstab query that puts together certain information perfectly. It has a criteria that is based on a form that limits how many columns are returned based on...
15
by: Richard Hollenbeck | last post by:
I tried to ask this question before on the 14th of January but I never got a reply. I'm still struggling with the problem. I'll try to rephrase the question: I have a crosstab query with rows...
3
by: Bryan | last post by:
I've been looking over this newsgroup, but I can't find an answer to my problem. I see that a few others have posted this issue over the years, but none of them got a response. I'll give it...
2
by: scott.k.fraley | last post by:
....and the SELECT thats trying to pull from said Query doesn't like it one bit! ;) I'm working on this project (in Access 2002) and there is a report who's RecordSource is the following...
6
by: tizmagik | last post by:
I am having a lot of difficulty generating a CrossTab Query based report. I have looked online for several tutorials and whatnot but I have not been able to really find what I'm looking for, nor...
6
by: Peter Herath | last post by:
I want to create a dynamic report using a crosstab query...... pls someone look into my attached example database and help me out to do the report generation.... example is like dis...: there...
0
by: Peter Herath | last post by:
I want to create a custormizable report . For an example, there's a form with four combo boxes and two of them having database tables columns/field names as values in the combo box(one for select row...
8
by: Paul H | last post by:
I want to base a form on a crosstab query. The query shows statistics for a user defined period. The column headings will look something like this: ClientID Month01 Month02 Month03 etc.. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.