I followed the MS Knowledge Base Article ID: Q208529 to create a pop-up form to filter a report. I need my pop-up window to have seven fields, four for text strings and three for date fields. My questions are:
1. How do I tell Access that a particular field is either
a date field or string when the strSQL is being put
together?
2. What is the 5 in the statement below mean?
strSQL = Left(strSQL, (Len(strSQL) - 5))
I'm including the relevant Event Procedure script below. thanks,
-----------------------------------
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 7
If Me("Filter" & intCounter) <> "" Then
'strSQL = strSQL & "[" & Me("Filter" & _
intCounter).Tag & "] " _
'& " = " & Chr(34) & Me("Filter" & _
intCounter) & Chr(34) & "" _
'And ""
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
--------------------------------------------
1. How do I tell Access that a particular field is either
a date field or string when the strSQL is being put
together?
2. What is the 5 in the statement below mean?
strSQL = Left(strSQL, (Len(strSQL) - 5))
I'm including the relevant Event Procedure script below. thanks,
-----------------------------------
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 7
If Me("Filter" & intCounter) <> "" Then
'strSQL = strSQL & "[" & Me("Filter" & _
intCounter).Tag & "] " _
'& " = " & Chr(34) & Me("Filter" & _
intCounter) & Chr(34) & "" _
'And ""
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
--------------------------------------------