From: Jim Murray Jim on
I've gotten this to work for me, but the sequence is reversed. The entry with
the highest # primary key is listed 1st, then down to the oldest. What have I
done wrong?

SELECT FormalCharges.UniqueID, Count(FormalCharges_1.UniqueID) AS Sequence,
FormalCharges.DefendantID
FROM FormalCharges INNER JOIN FormalCharges AS FormalCharges_1 ON
(FormalCharges.DefendantID = FormalCharges_1.DefendantID) AND
(FormalCharges.UniqueID <= FormalCharges_1.UniqueID)
GROUP BY FormalCharges.UniqueID, FormalCharges.DefendantID
HAVING (((FormalCharges.DefendantID)=[Forms]![AddForm]![DefendantID]))
ORDER BY FormalCharges.UniqueID;

From: John Spencer on
Try changing <= to >=

SELECT FormalCharges.UniqueID, Count(FormalCharges_1.UniqueID) AS Sequence,
FormalCharges.DefendantID
FROM FormalCharges INNER JOIN FormalCharges AS FormalCharges_1 ON
(FormalCharges.DefendantID = FormalCharges_1.DefendantID) AND
(FormalCharges.UniqueID >= FormalCharges_1.UniqueID)
GROUP BY FormalCharges.UniqueID, FormalCharges.DefendantID
HAVING (((FormalCharges.DefendantID)=[Forms]![AddForm]![DefendantID]))
ORDER BY FormalCharges.UniqueID;

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================


Jim Murray wrote:
> I've gotten this to work for me, but the sequence is reversed. The entry with
> the highest # primary key is listed 1st, then down to the oldest. What have I
> done wrong?
>
> SELECT FormalCharges.UniqueID, Count(FormalCharges_1.UniqueID) AS Sequence,
> FormalCharges.DefendantID
> FROM FormalCharges INNER JOIN FormalCharges AS FormalCharges_1 ON
> (FormalCharges.DefendantID = FormalCharges_1.DefendantID) AND
> (FormalCharges.UniqueID <= FormalCharges_1.UniqueID)
> GROUP BY FormalCharges.UniqueID, FormalCharges.DefendantID
> HAVING (((FormalCharges.DefendantID)=[Forms]![AddForm]![DefendantID]))
> ORDER BY FormalCharges.UniqueID;
>