Criteria from ComboBox

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

Guest

My querry gets the criteria from a ComboBox.
eample:
Acct Nubers(text)
11111
22222
33333
11111 or 22222
When I choose single account #s such as 11111, I get all the trans with acct
# 11111
But if I want acct #s 11111 or 22222, then the querry does not give any info
at all. I have tried quotation marks like "11111" or "22222" but the creteria
does not work
What am I missing?
I used a similar concept using a textBox, but no luck!
 
A parameter in a query can substitute only a single value. So, you can use
a parameter where a simple literal would otherwise be allowed. If your
query says:

WHERE AcctNo = [Forms]![MyForm]![MyCombo]

... then when you select 11111 or 22222 the query ends up interpreting it as:

WHERE AcctNo = "11111 or 22222"

... when what you really want is:

WHERE AcctNo = "11111" Or AcctNo = "22222"

The only way to get it to work correctly is to abandon the parameter query
and write code in the form that interprests the selection, builds the
correct predicate, and opens a form or report based on the query using a
WhereCondition parameter.

--
John Viescas, author
"Building Microsoft Access Applications" (Coming Soon!)
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
It is pretty unusual that a combo box allows you to select more than one
item. For instance, when
you order on Amazon.com and they provide a combo box for the State to ship
to, you can only choose
one state. So, if you have enabled a combo box where multiple selections are
possible you are clearly
a more advanced user than I. If on the other hand you are still talking
about a single entry in the combo
box, but have entries that consist of strings of other entries, then I think
you are going about this all wrong.
I would expect that your query is set to the value of your combo box via an
expression in the criteria row
like: =Forms!frmAccounts!cbo1
Could you perhaps post again and give some more details about how you have
gotten to this point?

Ed G
 
Back
Top