L
Linda RQ
Hi Everyone,
Using Access 2003. I have my query working....almost. I need to see
patients who have been on therapy for more than 10 days. I have a field
ThpyStDtTm and in my query grid, my Criteria is <=DateAdd("d",-10,Date()).
This shows me all the records of therapy that is >10 days old. The problem
is it is not showing me the records for that patient that are less than 10
days old and I need to see these records too but only for the patients on
therapy more than 10 days.
I am thinking I need to take the criteria off of my ThpyStDtTm field and add
a new field to my query grid with an expression that includes the
<=DateAdd("d",-10,Date()) with something else to say show all the records
for this patient but I don't know how to say this in query language.
Hope it can be done....I am so close!
Thanks, Linda
My sql is below so you can see all my tables and joins but I use the query
grid to get this.
SELECT tblAreaList.AreaSortOrder, tblAreaList.AreaName, [PtLocRmNum] & "
"& [BedNumber] AS RmAndBd, [PtLocRmNum] & " " & [BedNumber] & " " &
[PtLName] & ", " & [PtFName] & " ( " & [AdmitNum] & ")" AS
PtNameRmAdmitNum, tblPatients.AdmitNum, tblTherapyType.TherapyDesc,
tblFrequency.Freq, tblPatients.PtLName, tblPatients.PtFName,
tblPatients.PtActive, tblPatients.Isolation, tblPtThpy.ProtocolEvalDate,
tblPatients.PtMemo, tblPtLocation.PtLocStDtTm, tblPtLocation.PtLocEnDtTm,
tblPtLocation.PtLocRmNum, tblBedsList.BedNumber, tblPtThpy.ThpyStDtTm,
tblPtThpy.ThpyEndDtTm, tblPtThpy.ThpyCurrOrdNum, tblPtThpy.ThpyRenDate,
tblPtThpy.ThpyOrigOrdNum, tblPtThpy.ThpyHomeMeds, tblEquipType.TagNum,
[Model] & " " & [TagNum] AS VentAndTag, tblEquipType.Model,
tblPatients.Diagnosis, tblMedList.Med, tblPhysicians.PhysLName,
tblPhysicians.PhysFName, [PhysLName] & ", " & [PhysFName] AS Physician,
tblTherapyType.ThpySortOrder, tblPatients.TxPrtclCan, tblPatients.AppThpy,
tblPatients.AuditorMemo, DateDiff("d",[ThpyStDtTm],Date()) AS DaysInTherapy
FROM (tblPatients LEFT JOIN (tblAreaList RIGHT JOIN (tblBedsList RIGHT
JOINtblPtLocation ON tblBedsList.BedID = tblPtLocation.BedID_fk) ON
tblAreaList.AreaID = tblPtLocation.AreaID_fk) ON tblPatients.PtID =
tblPtLocation.PtID_fk) LEFT JOIN (tblTherapyType RIGHT JOIN (tblEquipType
RIGHT JOIN (tblFrequency RIGHT JOIN (tblPhysicians RIGHT JOIN (tblPtThpy
LEFT JOIN tblMedList ON tblPtThpy.ThpyMeds_fk = tblMedList.MedID) ON
tblPhysicians.PhysID = tblPtThpy.PhysID_fk) ON tblFrequency.FreqID =
tblPtThpy.FreqID_fk) ON tblEquipType.EquipID = tblPtThpy.EquipID_fk) ON
tblTherapyType.TherapyTypeID = tblPtThpy.ThpyTypeID_fk) ON
tblPatients.PtID= tblPtThpy.PtID_fkWHERE (((tblPatients.PtActive)=True) AND
((tblPtLocation.PtLocEnDtTm) Is
Null) AND ((tblPtThpy.ThpyStDtTm)<=DateAdd("d",-10,Date())))
ORDER BY tblAreaList.AreaSortOrder, tblTherapyType.ThpySortOrder;
Using Access 2003. I have my query working....almost. I need to see
patients who have been on therapy for more than 10 days. I have a field
ThpyStDtTm and in my query grid, my Criteria is <=DateAdd("d",-10,Date()).
This shows me all the records of therapy that is >10 days old. The problem
is it is not showing me the records for that patient that are less than 10
days old and I need to see these records too but only for the patients on
therapy more than 10 days.
I am thinking I need to take the criteria off of my ThpyStDtTm field and add
a new field to my query grid with an expression that includes the
<=DateAdd("d",-10,Date()) with something else to say show all the records
for this patient but I don't know how to say this in query language.
Hope it can be done....I am so close!
Thanks, Linda
My sql is below so you can see all my tables and joins but I use the query
grid to get this.
SELECT tblAreaList.AreaSortOrder, tblAreaList.AreaName, [PtLocRmNum] & "
"& [BedNumber] AS RmAndBd, [PtLocRmNum] & " " & [BedNumber] & " " &
[PtLName] & ", " & [PtFName] & " ( " & [AdmitNum] & ")" AS
PtNameRmAdmitNum, tblPatients.AdmitNum, tblTherapyType.TherapyDesc,
tblFrequency.Freq, tblPatients.PtLName, tblPatients.PtFName,
tblPatients.PtActive, tblPatients.Isolation, tblPtThpy.ProtocolEvalDate,
tblPatients.PtMemo, tblPtLocation.PtLocStDtTm, tblPtLocation.PtLocEnDtTm,
tblPtLocation.PtLocRmNum, tblBedsList.BedNumber, tblPtThpy.ThpyStDtTm,
tblPtThpy.ThpyEndDtTm, tblPtThpy.ThpyCurrOrdNum, tblPtThpy.ThpyRenDate,
tblPtThpy.ThpyOrigOrdNum, tblPtThpy.ThpyHomeMeds, tblEquipType.TagNum,
[Model] & " " & [TagNum] AS VentAndTag, tblEquipType.Model,
tblPatients.Diagnosis, tblMedList.Med, tblPhysicians.PhysLName,
tblPhysicians.PhysFName, [PhysLName] & ", " & [PhysFName] AS Physician,
tblTherapyType.ThpySortOrder, tblPatients.TxPrtclCan, tblPatients.AppThpy,
tblPatients.AuditorMemo, DateDiff("d",[ThpyStDtTm],Date()) AS DaysInTherapy
FROM (tblPatients LEFT JOIN (tblAreaList RIGHT JOIN (tblBedsList RIGHT
JOINtblPtLocation ON tblBedsList.BedID = tblPtLocation.BedID_fk) ON
tblAreaList.AreaID = tblPtLocation.AreaID_fk) ON tblPatients.PtID =
tblPtLocation.PtID_fk) LEFT JOIN (tblTherapyType RIGHT JOIN (tblEquipType
RIGHT JOIN (tblFrequency RIGHT JOIN (tblPhysicians RIGHT JOIN (tblPtThpy
LEFT JOIN tblMedList ON tblPtThpy.ThpyMeds_fk = tblMedList.MedID) ON
tblPhysicians.PhysID = tblPtThpy.PhysID_fk) ON tblFrequency.FreqID =
tblPtThpy.FreqID_fk) ON tblEquipType.EquipID = tblPtThpy.EquipID_fk) ON
tblTherapyType.TherapyTypeID = tblPtThpy.ThpyTypeID_fk) ON
tblPatients.PtID= tblPtThpy.PtID_fkWHERE (((tblPatients.PtActive)=True) AND
((tblPtLocation.PtLocEnDtTm) Is
Null) AND ((tblPtThpy.ThpyStDtTm)<=DateAdd("d",-10,Date())))
ORDER BY tblAreaList.AreaSortOrder, tblTherapyType.ThpySortOrder;