Re: 2 Form Questions for the Group...



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


.



Relevant Pages

  • Re: Running a parameter query off more than one multi-select list box
    ... command button where a click of the command button opens a query with the ... selections in the multi-select list box as its criteria. ... For Each varItem In Me!List4.ItemsSelected ...
    (microsoft.public.access.formscoding)
  • Re: Search records that will show up in a list box on a form.
    ... >>> I have created command buttons that look for specific criteria from ... >>> query table. ... you could create a query that uses your criteria and base a report ... Private Sub cmdFilter_Click ...
    (microsoft.public.access.forms)
  • Re: Search records that will show up in a list box on a form.
    ... When I click on a command button the "Enter Parameter ... I did specify the query in the row source which holds the ... give me a little more detail on what criteria I would need to use for the ... Is it possible to insert a report in a form? ...
    (microsoft.public.access.forms)
  • Re: HELP HELP HELP HELP List box
    ... ' Build criteria string from selected items in list box. ... attached to the query, is this correct. ... Do note that a Query cannot have a command button. ...
    (microsoft.public.access.forms)
  • Form input into query
    ... Are you specifying your filter criteria in the Query ... Dim QryName As String ...
    (microsoft.public.access.formscoding)