combo box in continuous filter search form

M

michelleumich

Hi,
I am working with a continuous search form that uses a filter. The
form it is based off of provides a SQL example with a combo box, but
only gives code allowing for the combo box to have three values. My
combo box has over two hundred. How do I set up the code to filter
with whatever I select in my combo box but still make sure to return
results even if no scholarship name is selected? Here is the code I
have now:

If Me.cboProgram = -1 Then
strWhere = strWhere & "([Program] = True) AND "
ElseIf Me.Program = 0 Then
strWhere = strWhere & "([Program] = False) AND "
End If

Thanks in advance,
M
 
M

michelleumich

Steve,
thanks for responding. I will explain more. This is the same form
that you helped me with earlier, BTW. When you set up a combo box in a
form, you have three options for the entries that come up in your
combo box when you are filling in your form. These are in the "Row
Source Type" option under "Data" in properties of the combo box
itself. For the Row source type, i have my Row Source Type set up as
"Table/Query"
This is my Row Source:
SELECT ERATable.[Scholarship Name] FROM ERATable ORDER BY ERATable.
[Scholarship Name];

The form I started with used "Value List" as his row source type.
Becuase of that, in his code he used this:

If Me.cboProgram = -1 Then
strWhere = strWhere & "([Program] = True) AND "
ElseIf Me.Program = 0 Then
strWhere = strWhere & "([Program] = False) AND "
End If
Becuase he only had three values, I don't knwo how to alter this code
to my needs. Do you have any suggestions? Is my question more clear?
Thanks,
M
 
G

Guest

If I understand right, if the combo box is named "cboScholarshipName", you
would use something like this:

If not IsNull(Me.cboScholarshipName) Then
' this should be on one line
strWhere = strWhere & "([Scholarship Name] = '" &
Me.cboScholarshipName & "') AND "
End If

Somewhere in the Sub you would delete the " AND " (5 characters)


HTH
 

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