Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Crosstab query in subform

Status
Not open for further replies.

TrekBiker

Technical User
Nov 26, 2010
330
GB
I'm wanting to assemble data in several queries into a single form, including three subforms based on crosstab queries if possible, as they give a neat layout. PHV in thread 702-1347583 gave a way of doing this using modifications to the crosstabs like this, but I didn't understand.

He said
Code:
Amend your crosstab query to have fixed number of columns:
TRANSFORM ...
...
PIVOT pivotField IN (value1, value2, ...)

One of my crosstabs looks like this

Code:
PARAMETERS Forms!frmByJudge.sfmJudgeComments.Form.Company Text ( 255 ), Forms!frmByJudge.Category Text ( 255 );
TRANSFORM Sum(qryScoresCurrentCompany.[Presentation Score]) AS [SumOfPresentation Score]
SELECT qryScoresCurrentCompany.Criterion
FROM qryScoresCurrentCompany
WHERE (((qryScoresCurrentCompany.Category)=[forms]![frmByJudge].[Category]) AND ((qryScoresCurrentCompany.Company)=[Forms]![frmByJudge].[sfmJudgeComments].[form].[Company]))
GROUP BY qryScoresCurrentCompany.Criterion
PIVOT qryScoresCurrentCompany.Judge;

Any guidance would be much appreciated.




 
Try set the source object property of the subform control to the crosstab query.
Query.[Your query name]

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thanks, tried that but it doesn't list the available fields from the query for placement in the subform. I found this using the Form Wizard too, and read that a crosstab has dynamic columns, or something like that. Hence the PHV thread about doing a transformation, but I didn't understand in detail what he meant.
 
In my suggested solution, there is no subform. There is an empty subform control with just the crosstab query.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Ah, sorry. Tried this instead ..'

Capture_kh3zv9.jpg


... but got error #Name?
 
This works for me with a crosstab. The control type is Subform/Subreport and the Source Object property is Query.MyQueryName.

CrosstabSubformDesign_yb1xvz.png


CrosstabSubformForm_m9skmy.png


Is your form frmByJudge open?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Yes, it's open. Will have to return to this in a few hours, bike ride calls. Thanks.
 
Just Garmin Connect for 90 min local ride in the sunshine. Enjoy yours.

Can't replicate your example for some reason. This is the crosstab query

Crosstab_lnkhmw.jpg


This is design view

Design_View_gtdkfu.jpg


But get this error message

Error_zocaqz.jpg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top