I have been running make-table queries to create 10 tables (one for
each unit) that are exported to Excel spreadsheets. Because of my
limited knowledge with code, I've created 10 separate queries to do the
job and then run a macro to do the exporting. I know there must be a
way to generate the 10 tables with only one query and I think it
probably involves looping(?) through the query. I've read the previous
postings and anytime I try to apply the examples to my database I
cannot get it to work. I'm wondering if someone could explain how to do
this in a simple way. Here is the SQL for qryPainControlTables:
SELECT Units.Units, FewMoreQuestions.WorstPain,
FewMoreQuestions.PainControlled, Count(FewMoreQuestions.FMQIDCode) AS
CountOfFMQIDCode
FROM Units RIGHT JOIN (Questionnaire LEFT JOIN FewMoreQuestions ON
Questionnaire.[ID Code] = FewMoreQuestions.SurveyIDCode) ON
Units.Number = Questionnaire.Unit
WHERE (((Questionnaire.[Survey Date]) Between
[Forms]![frmDates]![FirstDate] And [Forms]![frmDates]![LastDate]) AND
((FewMoreQuestions.WorstPain) Is Not Null And
(FewMoreQuestions.WorstPain)<>0) AND ((FewMoreQuestions.PainControlled)
Is Not Null And (FewMoreQuestions.PainControlled)<>0))
GROUP BY Units.Units, FewMoreQuestions.WorstPain,
FewMoreQuestions.PainControlled;