473,405 Members | 2,160 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,405 software developers and data experts.

Problem with Crosstab Query in subform

Hi, I'm fairly new to access and have a little trouble with a crosstab query I've setup.

I have a main form where the user selects a project name and below in a subform, a crosstab query is displayed in a datasheet view. The info is dependant on the project picked.

What I tried to do is set the criteria in the the query to only show results that match the project name but I am having no success. If I type a name into the critera then it works but if I enter a field name from the form then I run into trouble.

This is the initial SQL that works:
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM First(tblWelderQualification.CertificateNo) AS FirstOfCertificateNo
  2. SELECT [First Name] & " " & [surname] AS Name
  3. FROM tblWelders INNER JOIN tblWelderQualification ON tblWelders.[Welder ID] = tblWelderQualification.[Welder ID]
  4. WHERE (((tblWelderQualification.Project)="filterCriteria"))
  5. GROUP BY [First Name] & " " & [surname], tblWelderQualification.Project
  6. PIVOT tblWelderQualification.[WPS No];
When I add a parameter and change the critera as below it fails.

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS [Forms]![frmQualReg]![Text5] Text ( 255 );
  2. TRANSFORM First(tblWelderQualification.CertificateNo) AS FirstOfCertificateNo
  3. SELECT [First Name] & " " & [surname] AS Name
  4. FROM tblWelders INNER JOIN tblWelderQualification ON tblWelders.[Welder ID] = tblWelderQualification.[Welder ID]
  5. WHERE (((tblWelderQualification.Project)=[Forms]![frmQualReg]![Text5]))
  6. GROUP BY [First Name] & " " & [surname], tblWelderQualification.Project
  7. PIVOT tblWelderQualification.[WPS No];
This fails also, I've only added a parameter here.

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS [Forms]![frmQualReg]![Text5] Text ( 255 );
  2. TRANSFORM First(tblWelderQualification.CertificateNo) AS FirstOfCertificateNo
  3. SELECT [First Name] & " " & [surname] AS Name
  4. FROM tblWelders INNER JOIN tblWelderQualification ON tblWelders.[Welder ID]=tblWelderQualification.[Welder ID]
  5. WHERE (((tblWelderQualification.Project)="filterCriteria"))
  6. GROUP BY [First Name] & " " & [surname], tblWelderQualification.Project
  7. PIVOT tblWelderQualification.[WPS No];
When it fails I get the following error from the form:
"You can't use a pass-through query or a non-fixed crosstab query as a record source for a subform or subreport.
Before you bind the subform or subreport to a crosstab query, set the query's ColumnHeadings property."

The reason for using the crosstab query is the number of colums is dynamic and I didn't want to use the pivotchart as my users are more used to the datasheet view.

Any help would be greatly appreciated. Thanks.
Jan 31 '07 #1
3 6562
nico5038
3,080 Expert 2GB
Crosstable queries are nasty to use for forms and reports.
The basic problem is the fact that the content of a column will be transformed into fieldnames.
Thus when your selection fails to deliver a value or has a new value, then a field will be missing or a new field will be missing.
Best to make sure that all different values are present by using an outerjoin query with a table holding all values.

Personally I often create first a temp table with the selected data and use that for the crosstable query to have no trouble with the selection in the crosstable query.

When a report will work for you, then I can supply you with VBA code to fill a report depending on the result, but the max number of rows will need to be known.

Nic;o)
Feb 1 '07 #2
outerjoin query? I'm not sure how this would be done but i think i undertand your concept
Feb 1 '07 #3
nico5038
3,080 Expert 2GB
Make a table with all values for the crosstable query.
JOIN that table with the original table and make the "value table" leading (click the JOIN line and chose option 2 or 3)
Now there will always be a value, even a Null will show.
I use the trick e.g. for having all 12 months and by joining to a field with the month all months will show.

Nic;o)
Feb 2 '07 #4

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

Similar topics

3
by: Darleen | last post by:
I am seeking conceptual here on how to get started with a "3D Matrix" in Access. We run a training center which holds multiple classes in multiple cities at multiple times. So I need to create a...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
3
by: DFS | last post by:
I've been working around this for years (I believe), so I figured someone here might know: Why won't a crosstab query accept a value from a form reference? TRANSFORM...
1
by: krish_4u_only | last post by:
Hi, I have designed a subreport - record source is on crosstab query. crosstab query is designed on union query. The sub report is working fine when it is opened individually. but if i place it on...
0
by: Johnny M | last post by:
I have an unbound form with subforms. Some of the subforms are linked to each other using Master/child relationships (using hidden controls on the unbound form). I want to add a final subform to...
6
by: Michael R | last post by:
Please help me with this. I have a form in which I would like to present results from a CrossTab query in a subform. I don't need the query to be bounded to a master field. Also, I have a...
4
by: mattlightbourn | last post by:
Hi all, I have a problem which has been driving me nuts. Crosstab queries! I have a database witch a few different tables to do with garment manufacturing. I have a table for a client...
5
by: odavison | last post by:
I've created a Crosstab Query displaying the Consultant ID and the corresponding amount of Appointments they have on a specific date, as well as a count of the number of appointments. I am trying...
2
by: Jim Devenish | last post by:
I wish to create a crosstab query as the record source for a report. It needs to count data between selected dates which are entered by the user in a popup window. The following Select query...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.