Craftsman61
MIS
What I have is a button click event where from a form the user inputs a string (text or integer)in a text box or select an item from a combo box, after entering or selecting data in one or several of the "boxes" then fires the code below to display the results.
My issue is that only the "box" the farthest down the list becomes the main search criteria. In other words if several text boxes and one combobox was used the "box" farthest down the code line becomes the main, and only search criteria used. What i need is for all entry boxes to used if data is entered or selected in them for the filter.
My second issue is on the clear filter code it "resets or clears" any data entered or selected in the "boxes" but does not reset what the user is seeing. What I mean by reset is that until the filter is used all entries are listed on the screen for the user to view.
Any advice or direction to go in would be appreciated as I am not very good with vb and it took me a week to comeup with what I've got so far. Thanks in advance !!!!
Public Sub cmdFIND_Click()
' this filters the DB to show user data for filtering purposes.
Dim filstr As String
filstr = ""
If Me.txtFIND_summary <> "" Then
filstr = "SUMMARY LIKE '*" & txtFIND_summary & "*'"
End If
If Me.txtdescfilter <> "" Then
If filstr <> "" Then filstr = filstr & " or "
filstr = filstr & "change LIKE '*" & txtdescfilter & "*'"
End If
If Me.txtreasonfilter <> "" Then
If filstr <> "" Then filstr = filstr & " or "
filstr = filstr & "reason LIKE '*" & txtreasonfilter & "*'"
End If
If Me.cboKW1_FILTER <> "" Then
If filstr <> "" Then filstr = filstr & " or "
filstr = filstr & "KW1 LIKE '*" & cboKW1_FILTER & "*'"
End If
If Me.cboKW2_FILTER <> "" Then
If filstr <> "" Then filstr = filstr & " or "
filstr = filstr & "KW2 LIKE '*" & cboKW2_FILTER & "*'"
End If
If Me.cboKW3_FILTER <> "" Then
If filstr <> "" Then filstr = filstr & " or "
filstr = filstr & "KW3 LIKE '*" & cboKW3_FILTER & "*'"
End If
Me.Filter = filstr
Me.FilterOn = True
End Sub
Private Sub Clear_Click()
' THIS CLEARS THE SEARCH CRITERIA FROM THE BOXES
Me.cboKW1_FILTER = ""
Me.cboKW2_FILTER = ""
Me.cboKW3_FILTER = ""
Me.txtdescfilter = ""
Me.txtFIND_summary = ""
Me.txtreasonfilter = ""
End Sub
![[bigears] [bigears] [bigears]](/data/assets/smilies/bigears.gif)
My issue is that only the "box" the farthest down the list becomes the main search criteria. In other words if several text boxes and one combobox was used the "box" farthest down the code line becomes the main, and only search criteria used. What i need is for all entry boxes to used if data is entered or selected in them for the filter.
My second issue is on the clear filter code it "resets or clears" any data entered or selected in the "boxes" but does not reset what the user is seeing. What I mean by reset is that until the filter is used all entries are listed on the screen for the user to view.
Any advice or direction to go in would be appreciated as I am not very good with vb and it took me a week to comeup with what I've got so far. Thanks in advance !!!!
Public Sub cmdFIND_Click()
' this filters the DB to show user data for filtering purposes.
Dim filstr As String
filstr = ""
If Me.txtFIND_summary <> "" Then
filstr = "SUMMARY LIKE '*" & txtFIND_summary & "*'"
End If
If Me.txtdescfilter <> "" Then
If filstr <> "" Then filstr = filstr & " or "
filstr = filstr & "change LIKE '*" & txtdescfilter & "*'"
End If
If Me.txtreasonfilter <> "" Then
If filstr <> "" Then filstr = filstr & " or "
filstr = filstr & "reason LIKE '*" & txtreasonfilter & "*'"
End If
If Me.cboKW1_FILTER <> "" Then
If filstr <> "" Then filstr = filstr & " or "
filstr = filstr & "KW1 LIKE '*" & cboKW1_FILTER & "*'"
End If
If Me.cboKW2_FILTER <> "" Then
If filstr <> "" Then filstr = filstr & " or "
filstr = filstr & "KW2 LIKE '*" & cboKW2_FILTER & "*'"
End If
If Me.cboKW3_FILTER <> "" Then
If filstr <> "" Then filstr = filstr & " or "
filstr = filstr & "KW3 LIKE '*" & cboKW3_FILTER & "*'"
End If
Me.Filter = filstr
Me.FilterOn = True
End Sub
Private Sub Clear_Click()
' THIS CLEARS THE SEARCH CRITERIA FROM THE BOXES
Me.cboKW1_FILTER = ""
Me.cboKW2_FILTER = ""
Me.cboKW3_FILTER = ""
Me.txtdescfilter = ""
Me.txtFIND_summary = ""
Me.txtreasonfilter = ""
End Sub
![[bigears] [bigears] [bigears]](/data/assets/smilies/bigears.gif)