-----Original Message-----
Yes, you would have to run a separate query for each question.
No, I do not want to see your database. I'm happy to try to answer specific
questions in these newsgroups for free, but if you want me to analyze your
database, we'll have to go offline and talk about my hourly rates. Send me
an email at JohnV at Viescas.com if you're interested in pursuing this
further.
--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Would I have to do teh below SQL for each Question???
The reason being is that Its totally dependant on whta the
user selects as to what question is pulled?
Would it be easier if you had a quick scan at the
database? so you have a better understanding and then
maybe you could assist further based on what you see??
Many Thanks
James
-----Original Message-----
If this is a "one off" project, you can probably make it
work with the table
structure you have. Yes, Percent is a reserved word, so
I should have
enclosed it in brackets. Your query for question 1 might
look like:
SELECT Count(Q01)/(SELECT Count(*) FROM MyTable As M2) As
PercentQ01
FROM [MyTable]
WHERE [MyTable].Q01= [Forms]![MyForm]![cbo1]
AND [MyTable].Gender = [Forms]![MyForm]![cbo2]
... where cbo1 contains True or False and cb02 contains
the gender desired.
"MyTable" is the name of your table, and "MyForm" is the
name of your form.
--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
message
Ok this I understand...
The user only wants to input the following information:
Gender
Answer to questions
and then get a percentage out of the results...
So all she wants is litrally what I have set up... 25
Questions just labled Q01 - Q25 and all the answers are
True or False and then she just wants the Gender...
Is all hwat you have said still need to be done?
Many Thanks
James
-----Original Message-----
You have two problems:
1) You cannot specify a field name with a parameter
2) Your table is badly designed - it violates First
Normal Form (repeating
group)
You can either redesign your table and use a query
similar to what I
suggested or you must write code to dynamically create
the query with the
correct field name. Your table design should look
something like:
tblQuestionnaires - QuestionnaireID, Description,
Requestor, etc.
tblQuestions - QuestionnaireID, QuestionID,
QuestionType,
QuestionText
tblRespondents - RespondentID, Name, Gender, Address,
eMail, etc.
tblQuestionResponses - RespondentID, QuestionnaireID,
QuestionID, Answer
Note that the above design allows you to define an
infinite number of
questionnaires, a variable number of questions per
questionnaire, and an
infinite number or respondents, and to track the
responses to each
questionnaire/question/respondent combination.
Designed
like this, it's a
simple matter to create a parameter query that joins
tblRespondents (to get
Gender) with tblQuestionResponses to count, get
percentages, and do all
sorts of analysis.
--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
message
Ok well it looks more like...
Gender,Q01,Q02 ETC TO Q25
There all value lists with certain values as the
answers
i.e. True False
Does this affect the query Any?
Many Thanks
James
-----Original Message-----
Assuming your table looks something like:
QuestionID, Question, Answer, Gender
Then the solution will look something like:
SELECT Count(Question)/(SELECT Count(*) FROM
MyTable As
M2 WHERE M2.Question
= [Forms]![MyForm]![cbo1]) As Percent
FROM MyTable
WHERE MyTable.Question = [Forms]![MyForm]![cbo1]
AND MyTable.Answer = [Forms]![MyForm]![cbo2]
AND MyTable.Gender = [Forms]![MyForm]![cbo3]
--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
in
message
Hello I have a form and on this form I have 3
combo
boxes...
Lets just say there called:
cbo1
cbo2
cbo3
I would like to have a query where by it
calculates
the
total number of records the criteria above
specifies
and
also a percentage out of them records...
So something like 20% of 200 Records.
So for example the criteria may be:
Q01
Answer as True
Female
Then it would be like 20% of the 200 records that
have
been answered... So as the amount of records go
up in
the
table so will the no of records on the form...
Where
by
the percentage may change according to teh
results....
Can anyone assist?
Many Thanks
James
.
.
.
.