Follow Up question to the below posted by Allen Browne on 02/06/2005 -
Could something like this work for a form that has a subform and the
subform is a datasheet?
__________________________________________________ _____________________
Re: Multiple Sort in a Continuous Form - Similiar to AutoFilter
06 Feb 2005 06:21
Allen Browne
Okay, so you want to create a string that adds in the value of all the
non-blank combos.
This example is set up so that it creates a filter from any of the combos
that have a value. It tacks an " AND " on the end, so it's easy to add as
many as you wish. Then at the end it chops off the trailing " AND ", and
applies the filter.
You can code it in one of the combos, and then call the code from the other
combos to the filter gets applied as soon as any combo is updated.
Private Sub Combo49_AfterUpdate()
Dim strWhere As String
Dim lngLen As Long
If Me.Dirty Then Me.Dirty = False 'Save first
If Not IsNull(Me.Combo49) Then
strWhere = strWhere & "([IPT] = '" & Me.Combo49 & "') AND "
End If
If Not IsNull(Me.Combo83) Then
strWhere = strWhere & "([Tier5] = '" & Me.Combo83 & "') AND "
End If
'etc for other combos.
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
Private Sub Combo83_AfterUpdate()
Call Combo49_AfterUpdate
End Sub
Note that this example assumes:
- All these combos are unbound (for filtering only), and
- IPT, Tier5, etc are all Text type fields. Remove the extra quotes for
number fields.
--
Message posted via http://www.accessmonster.com