G
Guest
Hi,
I have a form that displays the Companies that I deal with. I use a combo
box and an unbound text box as my search tools to filter the data related to
the Companies. My problem is that when I enter the search criteria for Labor
Type (there are three choices = Union, Non-Union, n/a) as Union, for example,
I get all of the companies that are Union and Non-Union (not just the Union
records that I am looking for). How do I change my code to accomplish this?
I copied the code I used in my text box below.
Thanks in advance.
Jim
Private Sub txtSearch_AfterUpdate()
On Error Resume Next
Dim strSQL As String
Select Case Me.cboFindBy
Case "Show All Subs"
strWhere = strWhereCurrent
Case "Company"
strWhere = "WHERE [Company] Like '*" & Me.txtSearch & "*'"
Case "Contact #1"
strWhere = "WHERE [Contact #1] Like '*" & Me.txtSearch & "*'"
Case "Work Type"
strWhere = "WHERE [Work Type] Like '*" & Me.txtSearch & "*'"
Case "Labor Type"
strWhere = "WHERE [Labor Type] Like '*" & Me.txtSearch & "*'"
Case Else
Beep
MsgBox "The selected Find By option is not programmed."
Exit Sub
End Select
'strSelect is set in Form_Load event
strSQL = strSelect & strWhere
'MsgBox strSQL
Me.LstJobNo.RowSource = strSQL
End Sub
I have a form that displays the Companies that I deal with. I use a combo
box and an unbound text box as my search tools to filter the data related to
the Companies. My problem is that when I enter the search criteria for Labor
Type (there are three choices = Union, Non-Union, n/a) as Union, for example,
I get all of the companies that are Union and Non-Union (not just the Union
records that I am looking for). How do I change my code to accomplish this?
I copied the code I used in my text box below.
Thanks in advance.
Jim
Private Sub txtSearch_AfterUpdate()
On Error Resume Next
Dim strSQL As String
Select Case Me.cboFindBy
Case "Show All Subs"
strWhere = strWhereCurrent
Case "Company"
strWhere = "WHERE [Company] Like '*" & Me.txtSearch & "*'"
Case "Contact #1"
strWhere = "WHERE [Contact #1] Like '*" & Me.txtSearch & "*'"
Case "Work Type"
strWhere = "WHERE [Work Type] Like '*" & Me.txtSearch & "*'"
Case "Labor Type"
strWhere = "WHERE [Labor Type] Like '*" & Me.txtSearch & "*'"
Case Else
Beep
MsgBox "The selected Find By option is not programmed."
Exit Sub
End Select
'strSelect is set in Form_Load event
strSQL = strSelect & strWhere
'MsgBox strSQL
Me.LstJobNo.RowSource = strSQL
End Sub