Filter report from pop up form

R

riccifs

Hi to everyone,
I'm trying to use the code below in my report. I took it for the well-
know sample report collection.

Private Sub Command28_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 & "] "
& " = '" & _
& Me("Filter" & intCounter) & "' 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
Else
Reports![rptCustomers].FilterOn = False
End If

End Sub

It's working well until I try to filter a numeric filed. I know that
in this case I have to change the middle statement to:

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

But how can I merge the two sql statements to make them work at same
time? I mean, if Filed3 is a numeric filed then switch to the second
sql statement otherwise read the first one.

Many thanks to anyone would give to me an hand.
Bye, Stefano.
 

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