Re: 2 Form Questions for the Group...
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 10:52:42 +0800
Q1.
Not really clear, but I think you are looking for the IN operator, where one
field is matches against several values.
In the Criteria row under [Primary Search Field], you would enter:
IN ("some value", "another value", "third value")
or for a numeric field:
IN (3,6,7)
Other alternatives might be Switch() or Partition(), but I don't think they
do what you want.
Q2.
You cannot use a multi-select list box directly as the criteria in a query,
because the Expression Service will not parse the reference, and visit each
entry in the ItemsSelected.
You can programmatically create the string by looping through the
ItemsSelected collection. Once you have the WHERE clause, you can then
complete the SQL string, and assign it to the form's RecordSource. This can
be *much* more efficient than lots of " OR xxx Is Null" phrases in the WHERE
clause.
For an example of building the WHERE clause from a multi-select list box,
see:
Use a multi-select list box to filter a report
at:
http://allenbrowne.com/ser-50.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Peter Leman" <PeterLeman@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:47C417A4-68D1-4108-921D-75194718FB99@xxxxxxxxxxxxxxxx
> Question 1:
>
> Is there a command that will allow me (in queries for example) to match
> the
> conditions of one field to that of multiple fields or values? For
> example,
> in another data analysis tool I have used in the past, I could use
> Match([Primary Search Field], [Condition 1], [Condition 2], [Condition
> 3]).
> In other words, using this command, I could eliminate the need for
> multiple
> "iif" commands. Anyone know the function?
>
> Question 2:
> I have a form with list boxes that I am using to select filter criteria
> from
> before running a query. Within the query, I am using these commands:
>
> [Forms]![Form1]![Employee Name] Or [Forms]![Form1]![Employee Name] Is Null
>
> When I change the list boxes on the form to allow to me select multiple
> filter criteria (such as two employee names), it will bring back all of
> the
> records. How can I modify the command to filter (within the query) on the
> two employees selected in the form?
>
> Thanks - and to the regular posters, you guys are great! I have learned a
> ton from each of you.
>
> Peter Leman
.
- References:
- 2 Form Questions for the Group...
- From: Peter Leman
- 2 Form Questions for the Group...
- Prev by Date: Re: How do I populate a query with every fifth record?
- Next by Date: Then what is the better way --- Help!
- Previous by thread: 2 Form Questions for the Group...
- Next by thread: Crosstab Query?-NOT BLANK
- Index(es):
Relevant Pages
|
|