Hi All
I have been trying to use the following code to filter a form based on multiple combo boxes, problem i m having is that it keeps noting that "No Criteria", which is wrong it certainly does have crteria it should filter to....
Private Sub Combo34_AfterUpdate()
Dim strWhere As String
Dim lngLen As Long
If Me.Dirty Then Me.Dirty = False 'Save first
If Not IsNull(Me.Combo34) Then
strWhere = strWhere & "([Manufacturer] = '" & Me.Combo34 & "') AND "
End If
If Not IsNull(Me.Combo36) Then
strWhere = strWhere & "([SSM] = '" & Me.Combo36 & "') AND "
End If
lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lenLen > 0 Then
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
Else
MsgBox "No criteria."
End If
End Sub
Can anyone tell me what problem is, this is a great bit of code which would be wonderfull if i could figure this out...
ALi
I have been trying to use the following code to filter a form based on multiple combo boxes, problem i m having is that it keeps noting that "No Criteria", which is wrong it certainly does have crteria it should filter to....
Private Sub Combo34_AfterUpdate()
Dim strWhere As String
Dim lngLen As Long
If Me.Dirty Then Me.Dirty = False 'Save first
If Not IsNull(Me.Combo34) Then
strWhere = strWhere & "([Manufacturer] = '" & Me.Combo34 & "') AND "
End If
If Not IsNull(Me.Combo36) Then
strWhere = strWhere & "([SSM] = '" & Me.Combo36 & "') AND "
End If
lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lenLen > 0 Then
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
Else
MsgBox "No criteria."
End If
End Sub
Can anyone tell me what problem is, this is a great bit of code which would be wonderfull if i could figure this out...
ALi