Hi, Milez.
Add another textbox. For now leave it Visible while you get the code below
working. After you do, you can make it invisible. For now, I've assumed
that every textbox on the form is one of your order number input boxes.
Press <Ctrl-G> from from design view to open VBA. Cut and paste the code
below into the Module window, changing your formname and control name as
necessary. Save and exit.
Private Sub BuildControlString()
Dim ctl As Control
Dim strCriteria As String
strCriteria = ""
Forms!YourFormName!YourAddedTextboxControlName
' Loop through Form's Controls collection, building your criteria string
For Each ctl in Me.Controls
If (ctl.ControlType = acTextbox AND Not IsNull(ctl) )Then
strCriteria = strCriteria & ctl.Value & " OR "
End If
Next ctl
' Strip off last " OR "
strCriteria = Left(strCriteria,len(strCriteria)-4)
' Assign variable to hidden textbox
Forms!YourFormName!YourAddedTextboxControlName = strCriteria
End Sub
If you're using a command button to execute the query, insert the following
line at the top of the OnClick procedure:
Call BuildControlString
Then, in your query, set the Criteria to be equal to the hidden textbox
control.
Hope that helps.
Sprinks