Query referring to boolean field on form

  • Thread starter Thread starter Sietske
  • Start date Start date
S

Sietske

This query should only return the amount of questions which are answered
(checkbox in table is set to true), or only the amount of questions which are
not answered (checkbox is set to false). How should I write a single query,
which gives either one of the above results, depending on what is filled in
on a form?

I've tried the following, using a textfield (txtAnswered) on the form
containing either the word "true" or "false", but it didn't work. Or should I
in some way let the query refer to a checkbox on the form instead of a
textfield?

SELECT Count(tblQuestions.Id_Question) AS TotalAmountOfQuestions,
tblQuestions.Answered
FROM tblQuestions
GROUP BY tblQuestions.Answered
WHERE (((Forms!frmManagement!txtAnswered)=tblQuestions.Answered));
 
Help is no longer needed. It turned out to be quite easy, by using

SELECT Count(tblQuestions.Id_Question) AS TotalAmountOfQuestions,
tblQuestions.Answered
FROM tblQuestions
GROUP BY tblQuestions.Answered
HAVING
(((tblQuestions.Answered)=([Forms]![frmQuestionsAndAnswers]![txtAnswered])));

where txtAnswered contains the values -1 (=true) or 0 (false).
 
Back
Top