Hello,
I currently have a pop up form that filters data on another form. The pop up form has 7 fields. The first six work perfectly but the 7th one is a date. Below is my current code. I know you have to surround dates by # but I can't seem to figure out how to tweak the code to accept the 7th field filter as a date. Any ideas?
Private Sub Command11_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 "
End If
Next
If strSQL <> "" Then
' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 6))
' Set the Filter property.
Forms![frmSeverance].Filter = strSQL
Forms![frmSeverance].FilterOn = True
End If
End Sub
I currently have a pop up form that filters data on another form. The pop up form has 7 fields. The first six work perfectly but the 7th one is a date. Below is my current code. I know you have to surround dates by # but I can't seem to figure out how to tweak the code to accept the 7th field filter as a date. Any ideas?
Private Sub Command11_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 "
End If
Next
If strSQL <> "" Then
' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 6))
' Set the Filter property.
Forms![frmSeverance].Filter = strSQL
Forms![frmSeverance].FilterOn = True
End If
End Sub