reaktorblue
Board Regular
- Joined
- Aug 8, 2007
- Messages
- 87
- Office Version
- 365
- Platform
- Windows
Hello
I have a combo box on my form that gets values from qryTypes and I would like to be able to use these values as a part of my search form. The values display correctly on the form however, I suspect that the code in the VBA below is wrong for cboSearchType.
All I would like to be able to do is select a value from this drop down and include that as part of the search. So if I select Support in the drop down, I would like for the form to display all records with "Support" as the type.
Could anyone assist me with fixing my below code?
I have a combo box on my form that gets values from qryTypes and I would like to be able to use these values as a part of my search form. The values display correctly on the form however, I suspect that the code in the VBA below is wrong for cboSearchType.
All I would like to be able to do is select a value from this drop down and include that as part of the search. So if I select Support in the drop down, I would like for the form to display all records with "Support" as the type.
Could anyone assist me with fixing my below code?
Code:
Dim strWhere As String
Dim lngLen As Long
If Not IsNull(Me.txtSearchNetworkID) Then
strWhere = strWhere & "([NetworkID] Like ""*" & Me.txtSearchNetworkID & "*"") AND "
End If
If Not IsNull(Me.txtSearchFirstName) Then
strWhere = strWhere & "([FirstName] Like ""*" & Me.txtSearchFirstName & "*"") AND "
End If
If Not IsNull(Me.txtSearchLastName) Then
strWhere = strWhere & "([LastName] Like ""*" & Me.txtSearchLastName & "*"") AND "
End If
If Not IsNull(Me.cboSearchType) Then
strWhere = strWhere & "([Type] = " & Me.cboSearchType & ") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If