Type Mismatch

G

Guest

Hello all....

I am trying to use the following code to build an SQL string that is used to
filter a report. The problem I am having is a Type Mismatch error. I believe
this is because in one of my combo boxes (Filter1), there is a number, and
the others are all text.

The question is, how would I modify the code to accept a numeric value?

Thanks in advance....

________________________________-

Private Sub Set_Filter_Click()
Dim strSQL as String, intCounter as Integer

' Build SQL String.
For intCounter = 1 To 5
If Me("Filter" & intCounter) <> "" Then

strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _
& " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " _
And "
End If
Next

If strSQL <> "" Then
' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 5))

' Set the Filter property.
Reports![rptCustomers].Filter = strSQL
Reports![rptCustomers].FilterOn = True
End If
End Sub
 

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