E
Edgar Chado via AccessMonster.com
Hi to all,
I am using this code in the onclick event of a submit command button in a
Form which has two combo boxes which I use to filter a Report. This is a
pop up form.
The code works as long as the data types i use are text. The problem is
that i have a date datatype and a number datatype. So each timen I use
this form with these comboboxes I get a type mismatch error.
Could someone show me what to put into my code so dates are dates and
numbers numbers. I know that the error is associated to the Chr(34)
One more thing, the combo boxes are unbound.
Here is the code:
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 2
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![infReporte_Pedidos].Filter = strSQL
Reports![infReporte_Pedidos].FilterOn = True
End If
End Sub
I am using this code in the onclick event of a submit command button in a
Form which has two combo boxes which I use to filter a Report. This is a
pop up form.
The code works as long as the data types i use are text. The problem is
that i have a date datatype and a number datatype. So each timen I use
this form with these comboboxes I get a type mismatch error.
Could someone show me what to put into my code so dates are dates and
numbers numbers. I know that the error is associated to the Chr(34)
One more thing, the combo boxes are unbound.
Here is the code:
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 2
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![infReporte_Pedidos].Filter = strSQL
Reports![infReporte_Pedidos].FilterOn = True
End If
End Sub