Hi Steve,
First, its "Set db = CurrentDb"...
Second, one other advantage of putting
your report data into a temp table means
that you have different strategies for computing
the JudRank -- which for the purpose of the
xtab and report I believe needs each Judge to be
associated with a distinct integer *within an
Event/Level/AgeGroup group*.
For example, what happens if within one of these
groups one twirler has judges Harris/Jones/Brown
while other twirler has Simpson/Jones/Brown?
tblReport Event Level AgeGroup Twirler Score Rank Judge
Solo Advanced 10-12 Sally Smith 21.6 3 Harris
Solo Advanced 10-12 Sally Smith 45.3 1 Jones
Solo Advanced 10-12 Sally Smith 34.9 2 Brown
Solo Advanced 10-12 Mary Black 31.4 2 Simpson
Solo Advanced 10-12 Mary Black 63.5 1 Jones
Solo Advanced 10-12 Mary Black 21.8 3 Brown
By report data being in temp table, for the situation above,
we can create a distinct judges query (say "qryDistinctJudges")
SELECT DISTINCT Judge FROM tblReport;
Then we could use a domain function to get JudRank
in "qryupdJudRank"
UPDATE tblReport SET tblReport.JudRank = DCount("*","qryDistinctJudges","[Judge]<='" & [Judge] & "'");
giving
tblReport ID Event Level AgeGroup Twirler Score Rank Judge JudRank
1 Solo Advanced 10-12 Sally Smith 21.6 3 Harris 2
2 Solo Advanced 10-12 Sally Smith 45.3 1 Jones 3
3 Solo Advanced 10-12 Sally Smith 34.9 2 Brown 1
4 Solo Advanced 10-12 Mary Black 31.4 2 Simpson 4
5 Solo Advanced 10-12 Mary Black 63.5 1 Jones 3
6 Solo Advanced 10-12 Mary Black 21.8 3 Brown 1
so our xtab gives
qryxtabRpt Event Level AgeGroup Twirler Judge1JName Judge1Score Judge1Rank Judge2JName Judge2Score Judge2Rank Judge3JName Judge3Score Judge3Rank Judge4JName Judge4Score Judge4Rank
Solo Advanced 10-12 Mary Black Brown 21.8 3
Jones 63.5 1 Simpson 31.4 2
Solo Advanced 10-12 Sally Smith Brown 34.9 2 Harris 21.6 3 Jones 45.3 1
in report, Control Source for "txtJudgexJName" would be
=Max([JudgexJName])
Maybe that won't ever happen, or maybe it will be worse?
Also, is it possible you will have more than one
Event/Level/AgeGroup in tblReport?
If so, I imagine then you would change distinct query to
SELECT DISTINCT Event, Level, AgeGroup, Judge
FROM tblReport;
then to get distinct ranks over each group
UPDATE tblReport
SET tblReport.JudRank =
DCount("*","qryDistinctJudges",
"[Judge]<='" & [Judge] & "'
AND
[Event]='" & [Event] & "'
AND
[Level]='" & [Level] & "'
AND
[AgeGroup]='" & [AgeGroup] & "'");
I don't know....you know your data best...
good luck,
gary
Gary Walter said:
Crosstabs like temp tables and that's how
I would attack this report.
You have a filtering query to get the initial data.
Just once, change to make table (say "tblReport") and run.
Then, change to append query and save (say "qryapptblReport").
Add primary key autonumber "ID" field
to table you just created, plus "JudRank"
with Default Value of 0.
In the click event to open your report
'------------------
Dim db AS DAO.Database
Dim strSQL as String
Set db = CurrentDd
'clear temp table
db.Execute "DELETE * FROM tblReport", dbFailOnError
'run filter append query
db.Execute "qryapptblReport", dbFailOnError
'run update JudRank query (say saved as "qryupdJudRank")
db.Execute "qryupdJudRank", dbFailOnError
'open report that is based on saved crosstab query
DoCmd.OpenReport "rptXTab", acPreview
db.Close
'----------------------
That's basically how I would approach this
(except I would probably not depend on
stored queries, but would "spell them out"
into strSQL and execute strSQL instead)
for example....
'update JudRank
strSQL = "UPDATE tblReport AS M INNER JOIN tblReport AS P " _
& "ON (M.Twirler = P.Twirler) AND (M.AgeGroup = P.AgeGroup) " _
& "AND (M.Level = P.Level) AND (M.Event = P.Event) " _
& "SET M.JudRank = 1+[M].[JudRank] " _
& "WHERE [M].Judge >= [P].[Judge];"
db.Execute strSQL, dbFailOnError
good luck,
gary
Steve S said:
Thanks much Gary. sorry to take so long to get back and check for
responces
but other things got in the way. I think your last two posts will solve
my
problem. You tesated this with a table as initial input but I assume a
query
will work?
thanks again.