Finding using multiple text boxes

C

Chris

I have a main query I'd like to run with multiple fields, The goal is to set
up a form using text boxes in which the user can enter in values and search
the query according to what is entered.

My problem has to do with multiple text boxes. With multiple text boxes it
seems I must enter a value in every field for the query to present results. I
circumvented this problem but using "Null"/"Not Null" criteria for a previous
search that had only 2 text boxes, which leads to limited combinations to be
entered as criteria. But this new search is to have a significantly larger
number of text box fields.

Is there a way to have the query run with only data entered into selected
fields without figuring every single combination and making them criteria in
the query?
 
S

Sergey Poberezovskiy

I think that you have to write some code behind the form
that would check the text boxes and will construct your
criteria on the fly. Something similar to:

If Not IsNull(text1) Then
sCriteria = "Field1 = " & text1
End If

....

If Not IsNull(textN) Then
If Len(sCriteria) Then sCriteria = sCriteria & " And "
sCriteria = "FieldN = " & textN
End If

HTH
 
Top