Re: Filter Records with Multiple Combo Boxes
- From: "TC" <aatcbbtccctc@xxxxxxxxx>
- Date: 23 Dec 2005 06:12:59 -0800
I'd do it like this. Change the control/field names to suit.
(untested)
' module level declarations:
private gThis as string
private gThat as string
private gTother as string
Private Sub This_AfterUpdate()
gThis = trim$(me![This])
ReFilter
End Sub
Private Sub That_AfterUpdate()
gThat = trim$(me![That])
ReFilter
End Sub
Private Sub Tother_AfterUpdate()
gTother = trim$(me![This])
ReFilter
End Sub
private sub ReFilter()
dim s as string
if gThis <> "" then s = " AND ([This]=""" & gThis & """)"
if gThat <> "" then s = s & " AND ([That]=""" & gThat & """)"
if gTother <> "" then s = s & " AND ([Tother]=""" & gTother & """)"
if s = "" then
me.filteron = false
else
me.filter = mid$( s, 6)
me.filteron = true
endif
end sub
The abivge is a useful technique for building criteria strings when you
do not know how many of the criteria (if any) have been set. Note how
even the first string is given a leading " AND ". Thus, if the string s
is not empty, you know for sure that it starts with the 5 characters "
AND ", regardless of which criteria were or were not present - so you
just strip0 those leading characters, and you are left with a proper
boolean expression for use in the Filter prop.
HTH,
TC
.
- Follow-Ups:
- Re: Filter Records with Multiple Combo Boxes
- From: Dewey
- Re: Filter Records with Multiple Combo Boxes
- Prev by Date: Re: Forms based on Query & Data Entry
- Next by Date: Re: Altering Form to data entry based on combo box
- Previous by thread: Re: Displaying fields from one table in another table
- Next by thread: Re: Filter Records with Multiple Combo Boxes
- Index(es):
Relevant Pages
|