Almost there . . .

B

Bill Case

Hi Gary:

Thanks for the wonderful help so far. I've built the
form with four combo boxes, and when I search on one box
alone, it works brilliantly, however, when I search on
more than one box, it returns the following error:

Run-time error '3075':

Syntax error (missing operator) in query expression '(
AND RepCompany = 'CEW Lighting')'.

Here's the code I have in place:

Private Sub Command13_Click()

Dim strSQL As String

strSQL = ""

If IsNull(Me!EManfCombo) = False Then
If Len(strSQL) = 0 Then
strSQL = "Manufacturer = '" & Me.EManfCombo & "'"
Else
strSQL = "Manufacturer = '" & Me.EManfCombo & "'"
End If
End If

If IsNull(Me!EProdCombo) = False Then
If Len(strSQL) = 0 Then
strSQL = "Product = '" & Me.EProdCombo & "'"
Else
strSQL = " AND Product = '" & Me.EProdCombo & "'"
End If
End If

If IsNull(Me!ERepNameCombo) = False Then
If Len(strSQL) = 0 Then
strSQL = "RepName = '" & Me.ERepNameCombo & "'"
Else
strSQL = " AND RepName = '" & Me.ERepNameCombo
& "'"
End If
End If

If IsNull(Me!ERepCoCombo) = False Then
If Len(strSQL) = 0 Then
strSQL = "RepCompany = '" & Me.ERepCoCombo & "'"
Else
strSQL = " AND RepCompany = '" & Me.ERepCoCombo
& "'"
End If
End If

DoCmd.OpenReport "Electrical Catalogs", acViewPreview, ,
strSQL
DoCmd.Maximize

End Sub

.. . . . . .

Anything more you can offer will be greatly appreciated.
Again, thanks for getting me this far.
 
B

Bill Case

This should have been posted as a response to an earlier
post, not a new item. I apologize for the inconvenience.
 

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