Query referring to boolean field on form

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));
 
S

Sietske

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top