View Single Post
  #35  
Old March 3rd, 2007, 08:41 PM posted to microsoft.public.access.reports
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Calculating totals on a Crosstab Query

As always, double check the names of the controls on the
form to make sure they are identical to the names you use in
the query parameters.

I don't see where you explained which error message you
received and/or which parameter was causing it.

Your first query's WHERE clause is not quite right. Don't
use Like unless you really are doing a wildcard text
comparison.

WHERE [Mating Year] = Forms!FDailyWhelpingReport!MatingYear
AND (Dead = Forms!FDailyWhelpingReport!OptionDead
Or (Dead=IsNull(Forms!FDailyWhelpingReport!OptionDead )
AND [1st MATING] Is Not Null

The Dead test looks odd, the way it is written, the query
will return only records with Dead = True when you do not
specify OptionDead on the form.

If that still gives you trouble, remove the criteria one at
a time to see if it helps you locate the one that causing
trouble.

If you can deal with it, you can avoid all those extra [ ],
( ), and table names by never switching the query from SQL
view to the QBE grid. When you save a query from SQL view,
it will come back in SQL view.
--
Marsh
MVP [MS Access]


SBGFF wrote:
IF you like I could send you a db with just qrys and records you need to try
it out

This is the first qry, the one the crosstabs are built off.
Qry name is QDailyWhelpingReport

SELECT [98MatingRecords].[SHED #], [98MatingRecords].[NEST #],
[98MatingRecords].[FEMALE #], [98MatingRecords].[Mating Year],
[98MatingRecords].[WHELPING DATE], [98MatingRecords].Dead,
[98MatingRecords].[1st MATING]
FROM 98MatingRecords
WHERE ((([98MatingRecords].[Mating Year])=[Forms]![FDailyWhelpingReport]![MatingYear])
AND (([98MatingRecords].Dead) Like [Forms]![FDailyWhelpingReport]![OptionDead]
Or ([98MatingRecords].Dead)=IsNull([Forms]![FDailyWhelpingReport]![OptionDead]))
AND (([98MatingRecords].[1st MATING]) Is Not Null));

Next is the first crosstab you sent me,
Qry name is QDailyWhelpingReport_Shed

TRANSFORM Count(QDailyWhelpingReport.[NEST #]) AS [The Value]
SELECT QDailyWhelpingReport.[WHELPING DATE],
Count(QDailyWhelpingReport.[NEST #]) AS [Total Of NEST #]
FROM QDailyWhelpingReport
GROUP BY QDailyWhelpingReport.[WHELPING DATE]
PIVOT QDailyWhelpingReport.[SHED #];

Next The 2nd Crosstab you sent me
Qry name is QDailyWhelpingReport_SubTotal

TRANSFORM Count(IIf([Whelping Date] Is Null,Null,[NEST #])) AS Expr1
SELECT "SubTotal" AS Expr2,
Count(IIf([Whelping Date] Is Null,Null,[NEST #])) AS Expr3
FROM QDailyWhelpingReport
GROUP BY "SubTotal"
PIVOT QDailyWhelpingReport.[SHED #];

Next The 3rd Crosstab you sent me
Qry name is QDailyWhelpingReport_Total

TRANSFORM Count(QDailyWhelpingReport.[NEST #]) AS [CountOfNEST #]
SELECT "Total" AS Expr1,
Count(QDailyWhelpingReport.[NEST #]) AS [CountOfNEST #1]
FROM QDailyWhelpingReport
GROUP BY "Total"
PIVOT QDailyWhelpingReport.[SHED #];

Next The 4th Crosstab you sent me
Qry name is QDailyWhelpingReport_UnionQry

SELECT * FROM QDailyWhelpingReport_Shed
UNION ALL
SELECT * FROM QDailyWhelpingReport_SubTotal
UNION ALL SELECT * FROM QDailyWhelpingReport_Total;


"Marshall Barton" wrote
Crosstab queries generally require their parameters to be
declared, so that part is necessary. I need to see the
queries involved before I can hope to understand the rest of
what you're describing.

Sometimes you can unravel parameter issues by temporarily
repacing the parameter with a literal value. If that works,
then the problem is in the way the parameter value is
referenced or on the source of the parameter value. If the
literal value doesn't work either, then the problem is in
how the parameter is used.


SBGFF wrote:
The data type in the table is set to Number.Just got your last post.
To night I deleted every thing and started from scratch.Made a new qry and
every thing works till I try to open the first crosstab you made, then it
has an error concerning the parameter. I tried declaring the parameter in
the query, it then opened but there were no results. I tried declaring
them
in the qry your qry's are based on and I don't get any results, remove
them
and the qry works. remove them from the crosstab and I get the error.
Something ain't just quite right.
In the parameters data type in the qry, number is not there, the only
option
that it will let me use is Date/time