Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-Time error

Status
Not open for further replies.

trustsun

Technical User
Feb 4, 2004
73
US
Hi,

I'm getting a Run-time type mismatch 13 on this filter code.

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

Any advice or revision I should used?

-Thanks
 
Sure!

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

' Build SQL String.
For intCounter = 1 To 4
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) - 4))

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

Another note, the value from the combo boxes are text.
 
I cant see the error in this, but have had it lots of times.....

Start replacing varaibles in your SQL string, one at a time, until you do not get the error. That will narrow it down to the bit of the string that is failing, and you can investigate further.

you may want to start with the

& "" _
And ""

bit - consider trying & & " And "
 
You may try this:[tt]
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "]='" _
& Me("Filter" & intCounter) & "' AND "[/tt]


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top