Sue,
As I said earlier the SQL statement you posted will never return a last
name
or a first name. It will return a column with that name, however the
data
in the column will be the data that is in the PtID field. Are you sure
you
are posting the correct query?
SELECT tblPatientProtocolActivity.PtID AS LastName
, tblPatientProtocolActivity.PtID AS FirstName
, tblPatientProtocolActivity.PtID AS MRN
/// The above three lines will all return the same data - Pt ID///
If you are looking at the query grid (Design view) you would see the
following for the first three columns
Field: LastName: PtID
Table: tblPatientProtocolActivity
Field: FirstName: PtID
Table: tblPatientProtocolActivity
Field: MRN: PtID
Table: tblPatientProtocolActivity
SELECT tblPatientProtocolActivity.PtID AS LastName
, tblPatientProtocolActivity.PtID AS FirstName
, UCase(tblPatientProtocolActivity.PtID) AS MRN
, tblPatientProtocolActivity.ScreeningDate
, tblPatientProtocolActivity.[ICF date]
, tblPatientProtocolActivity.D1Tx
, tblPatientProtocolActivity.Comments
, tblPatientProtocolActivity.PtStatusID
, tblPatients.ApptDate, tblPatients.Time
, tblPatients.[Room#OfInpts] AS [Rm#]
, tblPatients.[ApptNeeded?]
, tblPatients.MDID
FROM tblPatients INNER JOIN tblPatientProtocolActivity
ON tblPatients.PtID = tblPatientProtocolActivity.PtID
WHERE tblPatientProtocolActivity.PtStatusID in (3,15,16)
ORDER BY tblPatientProtocolActivity.ScreeningDate DESC
, tblPatientProtocolActivity.[ICF date] DESC
, tblPatientProtocolActivity.D1Tx DESC;
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
Sue said:
Just in case it was mis-pasted, here's the SQL again. As I think about
it,
I
can probably account for one of the duplicates - I'm asking for
LastName,
FirstName, & MRN for patients for 2 separate protocols. Beyond that,
Lord
knows if you're stuck, John, I'm certainly unlikely to solve it -
you've
been
a huge help to me (and all of us on the board) many times.
Again, thanks for your thoughts & time.
SELECT tblPatientProtocolActivity.PtID AS LastName,
tblPatientProtocolActivity.PtID AS FirstName,
tblPatientProtocolActivity.PtID
AS MRN, tblPatientProtocolActivity.ScreeningDate,
tblPatientProtocolActivity.[ICF date], tblPatientProtocolActivity.D1Tx,
tblPatientProtocolActivity.Comments,
tblPatientProtocolActivity.PtStatusID,
tblPatients.ApptDate, tblPatients.Time, tblPatients.[Room#OfInpts] AS
[Rm#],
tblPatients.[ApptNeeded?], tblPatients.MDID
FROM tblPatients INNER JOIN tblPatientProtocolActivity ON
tblPatients.PtID
=
tblPatientProtocolActivity.PtID
WHERE (((tblPatientProtocolActivity.PtStatusID)=16 Or
(tblPatientProtocolActivity.PtStatusID)=15 Or
(tblPatientProtocolActivity.PtStatusID)=3))
ORDER BY tblPatientProtocolActivity.ScreeningDate DESC ,
tblPatientProtocolActivity.[ICF date] DESC ,
tblPatientProtocolActivity.D1Tx
DESC;
--
Thanks for your time!
:
I am stuck since the SQl you posted would never return a the LastName
or
the firstName from tblPatients.
It would return PtID three times. Two times with whatever case the
value was stored in and once in upper case.
Something is askew, but I don't know what.
'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
Sue wrote:
Data returned & there was no error message - the characters just
didn't
go to
uppercase.
I don't work in SQL, so I don't know how
"tblPatientProtocolActivityPtId"
wound up showing up multiple times.
The patient info data comes from tblPatients and consists of 3
fields -
LastName, FirstName, MRN. Each patient may be enrolled on multiple
protocols
(and vice versa), a many-to-many relationship. Their status for each
protocol
will be different. So there's a second table -
tblPatientProtocolActivity -
that uses the primary key from tblPatients and tblProtocols to keep
this info
separate.
I'm sure there are MANY more elegant ways to achieve what I'm doing,
but the
database is immensely useful to our workgroup and, except for this
uppercase/lowercase issue, it does everything I need except cook
breakfast.
Thank you!!