Hi John,
I'm sorry I wasted your time with creating
a tiebreaker with RND(). It would have worked
by *making a table* so Tiebreaker was set in stone,
but obviously as I used it, "2 randoms" are never
going to match. What was I thinking? Argh!
I was just trying to give each record a unique
"record number" from 3 fields that could be exactly
the same. Actually, if we went to the trouble of
making a table, we could just as easily emptied
a table with an autonumber field, and filled it
with qryOrig, forgetting RND() altogether (especially
since RND() would have needed *more adaptation*
because matching floats is a fool's dream on a computer...
CLng(100000*RND(VisitID)), or something like that).
But...nevermind.
In looking at your example data, I don't
know what will be wrong with including
tblTPN's pk?
tblTPN:
TPNID (pk)
VisitID
DateIVAccessIn
IVAccessType
tblVisits:
VisitID
MRNnew
qryOrig:
SELECT
tblVisits.MRNnew,
tblTPN.TPNID,
tblTPN.DateIVAccessIn,
tblTPN.IVAccessType
FROM tblVisits INNER JOIN tblTPN
ON tblVisits.VisitID = tblTPN.VisitID
WHERE
((Not (tblTPN.DateIVAccessIn) Is Null))
OR ((Not (tblTPN.IVAccessType) Is Null))
ORDER BY tblVisits.MRNnew;
qryTop3:
SELECT
t1.MRNnew,
t1.IVAccessType,
t1.DateIVAccessIn
FROM qryOrig AS t1
WHERE (((t1.TPNID) In
(SELECT TOP 3 q.TPNID
FROM qryOrig AS q
WHERE
q.MRNnew = t1.MRNnew
ORDER BY
q.DateIVAccessIn DESC,
q.TPNID)))
ORDER BY
t1.MRNnew,
t1.DateIVAccessIn DESC;
My ISP's mailserver is down at the moment,
but I will try to send zip back "in the future."
Please respond back if I have misunderstood
one more time.
Good luck,
Gary Walter