SELECT DISTINCTROW tblPatient.PtExtID, tblIndSelfAcceptance.IndDate,
tblIndSelfAcceptance.Episode, tblIndSelfAcceptance.IndSA1,
tblIndSelfAcceptance.IndSA2, tblIndSelfAcceptance.IndSA3,
tblIndSelfAcceptance.IndSA4, tblIndSelfAcceptance.IndSA5,
tblIndSelfAcceptance.IndSA6,
Sum(Nz([tblIndSelfAcceptance]![IndSA1],0)+Nz([tblIndSelfAcceptance]![IndSA2],0)+Nz([tblIndSelfAcceptance]![IndSA3],0)+Nz([tblIndSelfAcceptance]![IndSA4],0)+Nz([tblIndSelfAcceptance]![IndSA5],0)+Nz([tblIndSelfAcceptance]![IndSA6],0))
AS Score
FROM tblPatient LEFT JOIN tblIndSelfAcceptance ON tblPatient.PtExtID =
tblIndSelfAcceptance.PtExtID
GROUP BY tblPatient.PtExtID, tblIndSelfAcceptance.IndDate,
tblIndSelfAcceptance.Episode, tblIndSelfAcceptance.IndSA1,
tblIndSelfAcceptance.IndSA2, tblIndSelfAcceptance.IndSA3,
tblIndSelfAcceptance.IndSA4, tblIndSelfAcceptance.IndSA5,
tblIndSelfAcceptance.IndSA6
ORDER BY tblPatient.PtExtID;
So, patient with PtExtID 999 has a value of 1 for each of the 6 indicators,
the Score would be 6. My query returns 16. Pt #44444 has a total of 8
(1,+2+1+1+2+1) and Score reads 24. Go figure. What's worse is I can
almost see what's wrong, but not quite!
--
dlh
KARL DEWEY said:
Post the complete SQL of your query. Open in design view, click on VIEW - SQL
View, hightlight all, copy, and paste in a post.
:
Wow - quick response.
Indeed, I do have my tables set up as suggested. (Remembered that much.) I
did try the equation as you suggested and still get 18 where it should be 5,
etc..... I can see no ryhme or reason for the math. Scores can be 0, 1, or
2 up to a total of 12. Patient can have up to 10 evaluations (10 dates), but
that doesn't seem to be playing into the math, either.
--
dlh
:
What am I doing wrong?
You are trying to use Access as a spreadsheet instead of a relational
database.
Collect your data using two tables - patient & evaluations with a
one-to-many relationship on PatientID. Select Referential Integerity and
Cascade Update.
Use a form/subform for patient/evaluations data entry. Set the Master/Child
links using PatientID.
Use a union query to move your current data to the new evaluations table.
SELECT PatientID, EvalDate, IndSA1 AS Data
FROM YourTable
UNION ALL SELECT PatientID, EvalDate, IndSA2 AS Data
FROM YourTable
.........
UNION ALL SELECT PatientID, EvalDate, IndSA6 AS Data
FROM YourTable
To sum you present dat try this --
=Nz([IndSA1],0)+Nz([IndSA2],0)+Nz([IndSA3],0)+Nz([IndSA4],0)+Nz([IndSA5],0)+Nz([IndSA6],0)
:
I have a patient that gets evaluated at intake, 3mos, 6mos, etc for up to 10
episodes. I have the form and subform working correctly to add evaluation
data, but I cannot get a total score for each episode.
I need to add indicators 1-5 for a particular visit. I have a control in the
footer:
=[IndSA1]+[IndSA2]+[IndSA3]+[IndSA4]+[IndSA5]+[IndSA6]
but I get crazy totals. I need to limit to THIS patient, THIS date and
episode. What am I doing wrong?
It's been a very long time since I have worked in Access and this is
stopping me from moving forward. Thanks for any assistance.