Using the QBE, how can I have a query that returns only the checked boxes. For example, say I have 15 Yes/No boxes for each person to answer. How can I return only those boxes checked 'yes' for each person no matter the combination or number checked?
as far as i know you can't do it directly in the query.
here's what i did:
made a form that looks like it's a query dataset by setting Default View and Views Allowed both to Datasheet. Then I put code into the OnOpen event that makes a column hidden if it is NO (zero). This will only work if you are only returning one row/one person at a time. i made Table1 with field ID and five others Field1 - Field5 which are yes/no fields checked at random for 4 different records/people in your case.
the RecordSource =
SELECT Table1.* FROM Table1 WHERE (((Table1.ID)=[Enter ID:]));
bring all the fields down into the form design.
in the form's OnOpen event put:
On Error Resume Next
Dim myCtl As Control
For Each myCtl In Me.Controls
If myCtl = 0 Then
myCtl.Properties("ColumnHidden" = True
Else
myCtl.Properties("ColumnHidden" = False
End If
Next
I'm not sure exactly what you're after but if you could have these values as a single string, you could use the QBE.
Bring all of the question fields down into the query. I'll call them Q1 through Q15.
In the Field line of Q1, type
Code:
1: IIF([Q1] = Yes, "Q1 ","")
Question 2
Code:
2: IIF([Q2] = Yes, "Q2 ","")
and on through Q15.
In the next open column, type:
Code:
Yes: [1] & [2] & [3] & [4] & ... & [15]
This last column will be a string (eg: Q1 Q4 Q13 Q15) identifying the 'yes' answers. Of course you can substitute any text you want returned in the IIf statements.
HTH
John
Use what you have,
Learn what you can,
Create what you need.
Oh my god, you guy's make it seem so easy. What i'm looking for is a way to print up a report that only shows yes answers. I have a total of 15 YES/NO questions I would like my report to show just the Yes answers.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.