I am using the code below to filter a listbox. It works to filter the listbox. However I have a field “DaysSinceSent” where Like '*" & Me.txtDaysSinceSent & "*' does not accomplish what I need. “DaysSinceSent” is a number field and I want to return those records that exceed what is entered in “txtDaysSinceSent”. For example all records where “DaysSinceSent” is more that 90.
How do I modify this piece of code to filter on >= txtDaysSinceSent instead of Like?
If Not IsNull(Me.txtDaysSinceSent) Then
trWhere = strWhere & " (qryCaseLog.DaysSinceSent) Like '*" & Me.txtDaysSinceSent & "*' AND"
End If
Code Below is what I am working with. I removed a section to save looking through code that is functioning:
Private Sub Search_Click()
'Set the Dimensions of the Module
Dim strSQL As String, strOrder As String, strWhere As String
Dim dbNm As Database
Dim qryDef As QueryDef
Set dbNm = CurrentDb()
'Constant Select statement for the RowSource
strSQL = "SELECT qryCaseLog.ItemID, qryCaseLog.DateSentToAAG, qryCaseLog.RName,qryCaseLog.DaysSinceSent " & _
"FROM qryCaseLog"
strWhere = "WHERE"
'strOrder = "ORDER BY qryCaseLog.ItemID;"
strOrder = "ORDER BY qryCaseLog.RLastName , qryCaseLog.RFirstName" & " DESC"
'Set the WHERE clause for the Listbox RowSource if information has been entered into a field on the form
If Not IsNull(Me.txtCommitteeDecision) Then '<--If the textbox CommitteeDecision contains no data THEN do nothing
strWhere = strWhere & " (qryCaseLog.CommitteeDecision) Like '*" & Me.txtCommitteeDecision & "*' AND" '<--otherwise, apply the LIKE statment to the QueryDef
End If
<<<<<Section of Code Removed>>>>>
(The section below is what I am having issue with)
If Not IsNull(Me.txtDaysSinceSent) Then
trWhere = strWhere & " (qryCaseLog.DaysSinceSent) Like '*" & Me.txtDaysSinceSent & "*' AND"
End If
'Remove the last AND from the SQL statment
strWhere = Mid(strWhere, 1, Len(strWhere) - 5)
'Pass the SQL to the RowSource of the listbox
Me.List68.RowSource = strSQL & " " & strWhere & "" & strOrder
End Sub
Thanks
Accel45
How do I modify this piece of code to filter on >= txtDaysSinceSent instead of Like?
If Not IsNull(Me.txtDaysSinceSent) Then
trWhere = strWhere & " (qryCaseLog.DaysSinceSent) Like '*" & Me.txtDaysSinceSent & "*' AND"
End If
Code Below is what I am working with. I removed a section to save looking through code that is functioning:
Private Sub Search_Click()
'Set the Dimensions of the Module
Dim strSQL As String, strOrder As String, strWhere As String
Dim dbNm As Database
Dim qryDef As QueryDef
Set dbNm = CurrentDb()
'Constant Select statement for the RowSource
strSQL = "SELECT qryCaseLog.ItemID, qryCaseLog.DateSentToAAG, qryCaseLog.RName,qryCaseLog.DaysSinceSent " & _
"FROM qryCaseLog"
strWhere = "WHERE"
'strOrder = "ORDER BY qryCaseLog.ItemID;"
strOrder = "ORDER BY qryCaseLog.RLastName , qryCaseLog.RFirstName" & " DESC"
'Set the WHERE clause for the Listbox RowSource if information has been entered into a field on the form
If Not IsNull(Me.txtCommitteeDecision) Then '<--If the textbox CommitteeDecision contains no data THEN do nothing
strWhere = strWhere & " (qryCaseLog.CommitteeDecision) Like '*" & Me.txtCommitteeDecision & "*' AND" '<--otherwise, apply the LIKE statment to the QueryDef
End If
<<<<<Section of Code Removed>>>>>
(The section below is what I am having issue with)
If Not IsNull(Me.txtDaysSinceSent) Then
trWhere = strWhere & " (qryCaseLog.DaysSinceSent) Like '*" & Me.txtDaysSinceSent & "*' AND"
End If
'Remove the last AND from the SQL statment
strWhere = Mid(strWhere, 1, Len(strWhere) - 5)
'Pass the SQL to the RowSource of the listbox
Me.List68.RowSource = strSQL & " " & strWhere & "" & strOrder
End Sub
Thanks
Accel45