I have only gone so far as to do this much:
SELECT UniqueID, "AggressionVerbalPresent" As Behaviour
FROM Students
WHERE [AggressionVerbalPresent] = TRUE
UNION ALL
SELECT UniqueID, "AggressionPhysicalPresent"
FROM Students
WHERE [AggressionPhysicalPresent] = TRUE;
Then it shows this:
UniqueID Behaviour
1 AggressionVerbalPresent
2 AggressionVerbalPresent
4 AggressionVerbalPresent
6 AggressionVerbalPresent
7 AggressionVerbalPresent
8 AggressionVerbalPresent
9 AggressionVerbalPresent
10 AggressionVerbalPresent
etc it goes all the way down to 57 and then it starts from 1 again and lists
57 AggressionPhysicalPresent behaviours. I tried then creating a pivotal
chart in Access and then going over to Excel which is not what I really want
to do but it then showed up in excel with the right amounts in a chart which
is what I want.
Now I just need to add all the rest of the behaviours to the union query but
for some reason it's giving me an error, I'm not sure how to add more, do I
add it after the stuff I have above? Say I want to add
propertydamagepresent, which section of the query would I add that? Is there
a way then to do a chart in MS Access instead of having to go over to Excel?
Monique
That's working OK but I need to add all the rest of the behaviours
Duane Hookom said:
Please provide your final sql of your union query.
--
Duane Hookom
Microsoft Access MVP
:
Thanks for that, the query actually worked, once I twigged a few things, I
had to just call the table "students" as it didn't like tblstudents like you
had, then the primary key is actually UniqueID instead of StudentID as we are
only using students initals so we didn't want that to be the unique id, so I
created one.
Anyway the query ran, I only have 57 students in the db, all it showed was
the unique id and the behaviour which was "AggressionPhysicalPresent" but it
showed that for all of them, so I had 57 of each for every student and I know
that they don't all have that check box ticked, I thought the = TRUE would
get rid of any that didn't have that checkbox ticked?
Monique
:
You are close with your union query. I'm not sure if your table name is
tblStudents or "that table is just called students"...
This sql should be a good start if you have a Primary Key field StudentId
and your table name is tblStudents:
SELECT StudentID, "AggressionVerbalPresent" As Behaviour
FROM tblStudents
WHERE [AggressionVerbalPresent] = TRUE
UNION ALL
SELECT StudentID, "AggressionPhysicalPresent"
FROM tblStudents
WHERE [AggressionPhysicalPresent] = TRUE;
--
Duane Hookom
Microsoft Access MVP
:
I just tried to do a union query, I've never done them before, this is how I
did it:
SELECT StudentID, "AggressionVerbalPresent"
FROM tblStudents
WHERE [AggressionVerbalPresent] = TRUE
UNION ALL
SELECT StudentID, "AggressionPhysicalPresent"
FROM tblStudents
WHERE [AggressionPhysicalPresent] = TRUE
UNION ALL
But it didn't work, it came back with an error message "Syntex error in
query. Incomplete clause."
I'm not sure what I'm doing wrong, I have the record names exactly how they
are in the table, that table is just called students so I've done that. The
thing is when I say = TRUE, I think when a tick is used for a check box it
sees it as being -1 for some reason, I tried using both = TRUE and = -1 but
that didn't work either.
Monique
:
Your table structure sounds like a spreadsheet rather than a relational
database. Either normalize your structure or use a union query like
SELECT StudentID, "ADHD" as Behaviour
FROM tblStudentSpreadsheet
WHERE [ADHD] = True
UNION ALL
SELECT StudentID, "Autism"
FROM tblStudentSpreadsheet
WHERE [Autism] = True
UNION ALL
... etc ...
You can then create a graph based on the union query.
--
Duane Hookom
Microsoft Access MVP
:
I'm putting together a student database and to do some charts, I want to do a
pie chart with a break up of different behaviours by percentage, in the
actual form I've got check boxes against each student and have checked off
the behaviours displayed so I'm wondering how I can say 50% for example show
violence, 20% show impulsive behaviours etc etc when I don't have numbers as
such to draw from I only have check boxes against each child? Any ideas how
to do this.
I also want to do a graph as well with number of children with ADHD, number
with Autism etc etc, any help would really be appreciated.
Thanks