List Box in a QBF

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I originally creatd a Query by form and had the query reference the form by
entering
Like [Forms]![Search by Exch]![WhatExchange]

This worked perfectly fine when i had a drop down box (named WhatExchange)
and the user selected one of the options- this option was then used as the
criteria in the query. However when i tried to switch it to a list box (named
WhatExchange-i deleted the drop down box) instead of a drop down box- it no
longer works. Anybody have any ideas?
Thanks.
 
The reference should still work if this is NOT a multi-select list box.

If it is a multi-select, you cannot use it this way in the query. Instead,
you need to generate the WHERE clause programmatically, and then apply it in
the Filter of the form or the WhereCondition of the OpenReport action. For
an example of code to do that, see:
Use a multi-select list box to filter a report
at:
http://allenbrowne.com/ser-50.html
 
Allen-
Thanks for the help- A little bit complicated for me. I ran it in Northwind
and it worked great, but im not too sure how to use it in my own DB. Im
trying to get it to get it to open a query- not a report. Also, there are
additional criteria to select as well in the from- will this still work?
Thanks.
Joel


Allen Browne said:
The reference should still work if this is NOT a multi-select list box.

If it is a multi-select, you cannot use it this way in the query. Instead,
you need to generate the WHERE clause programmatically, and then apply it in
the Filter of the form or the WhereCondition of the OpenReport action. For
an example of code to do that, 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.

Reply to group, rather than allenbrowne at mvps dot org.

jjbf22 said:
I originally creatd a Query by form and had the query reference the form by
entering
Like [Forms]![Search by Exch]![WhatExchange]

This worked perfectly fine when i had a drop down box (named WhatExchange)
and the user selected one of the options- this option was then used as the
criteria in the query. However when i tried to switch it to a list box
(named
WhatExchange-i deleted the drop down box) instead of a drop down box- it
no
longer works. Anybody have any ideas?
Thanks.
 
Presumably it is a multi-select list box, then.

Yes, you can use a WhereCondition built by looping through the ItemsSelected
collection of a multi-select list box, and still add other AND phrases to
the string.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

jjbf22 said:
Allen-
Thanks for the help- A little bit complicated for me. I ran it in
Northwind
and it worked great, but im not too sure how to use it in my own DB. Im
trying to get it to get it to open a query- not a report. Also, there are
additional criteria to select as well in the from- will this still work?
Thanks.
Joel


Allen Browne said:
The reference should still work if this is NOT a multi-select list box.

If it is a multi-select, you cannot use it this way in the query.
Instead,
you need to generate the WHERE clause programmatically, and then apply it
in
the Filter of the form or the WhereCondition of the OpenReport action.
For
an example of code to do that, see:
Use a multi-select list box to filter a report
at:
http://allenbrowne.com/ser-50.html


jjbf22 said:
I originally creatd a Query by form and had the query reference the form
by
entering
Like [Forms]![Search by Exch]![WhatExchange]

This worked perfectly fine when i had a drop down box (named
WhatExchange)
and the user selected one of the options- this option was then used as
the
criteria in the query. However when i tried to switch it to a list box
(named
WhatExchange-i deleted the drop down box) instead of a drop down box-
it
no
longer works. Anybody have any ideas?
Thanks.
 
Back
Top