Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning YES ANSWERS

Status
Not open for further replies.

chubby

Programmer
Apr 28, 2001
278
US
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

should be enuf to get you started.

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

Thanks for all your help!!!!
chubby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top