Multiple values in criteria field

  • Thread starter Thread starter colettelamm
  • Start date Start date
C

colettelamm

Hello,
I am trying to run a query that only returns the results where ...
10A or 10B or 10C or 10D or 10E
are found.

If I literally type it into the query in the format
"10A" or "10B" or ...
It works.

When I try to retrieve the values from a field on a form or from a
function called from the query, it doesn't work. I am able to retrieve
the values from a field on a form successfully when there is only one
value.

I am trying to derive a number of different reports based on the same
set of queries and populating the criteria based on values in a
Reports Table. If I can not have more than one field, then I will need
to create separate queries with hard coded values.

Thank you,
Colette
 
Hi -

You didn't say how you are running the reports, but if you are using the
docmd.openreport... statement in the form code, the 4th parameter of the
docmd.openreport specifies the criteria for selecting the data for the
report, something like this:

DoCmd.OpenReport "Diagram Case Prtvar", acViewPreview, , "dataset_ID = "
& Me![dataset name].Column(1)

The criteria is a string just like the WHERE clause of a SQL select statement,
but without the WHERE.

In the example above, the criteria string might look like: "dataset_ID = 1" ,
and the whole command becomes:

DoCmd.OpenReport "Diagram Case Prtvar", acViewPreview, , "dataset_ID = 1"

By doing this you can make your queries very general, often with no built-in
criteria at all.

HTH

John
 
I am trying to run a query that only returns the results where ...
10A or 10B or 10C or 10D or 10E
are found.

If I literally type it into the query in the format
"10A" or "10B" or ...
It works.

When I try to retrieve the values from a field on a form or from a
function called from the query, it doesn't work. I am able to retrieve
the values from a field on a form successfully when there is only one
value.

I am trying to derive a number of different reports based on the same
set of queries and populating the criteria based on values in a
Reports Table. If I can not have more than one field, then I will need
to create separate queries with hard coded values.


If you enter something like 10A,10B,10C,10D,10E in the form
text box, then you can use a calculated field in the query
that is just the form/textbox reference. It's criteria
would be:

Like "*" & thetablefield & "*"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Access Dcount (multiple criteria) 3
Access to MySQL conversion 2
Return Bottom Values 12
Sorting in Excel 2
Default Query Criteria 1
Parameter Value in Crosstab Query 4
Query Criteria Not Working 2
multiple OR criteria 8

Back
Top