Parameter Query

G

Guest

Can I do a parameter query where the query returns based on the entered
parameter being found in any of 4 different fields? I have a subcontractor
table and for each sub I have 4 (more later) fields with that subs various
jobs. I want to query for only thos subs who are working on the [Martin]
job, for example. martin could be listed in any of the 4 fields.
 
J

John Vinson

Can I do a parameter query where the query returns based on the entered
parameter being found in any of 4 different fields? I have a subcontractor
table and for each sub I have 4 (more later) fields with that subs various
jobs. I want to query for only thos subs who are working on the [Martin]
job, for example. martin could be listed in any of the 4 fields.

Sure. Just put the parameter under each of these fields, ON SEPARATE
LINES of the query grid. This will use OR logic to search all four
fields and return the record if any one of them matches.

John W. Vinson[MVP]
 
D

Douglas J. Steele

You can, but be aware that a need to do so generally indicates that the
database hasn't been properly normalized.

Your WHERE clause would look like WHERE Field1 = [Parameter] Or Field2 =
[Parameter] Or Field3 = [Parameter] Or Field4 = [Parameter]. Make sure you
spell the parameter name identically in all 4 cases.

In the GUI query builder, you'd put the parameter on separate lines under
the 4 fields. If there are additional elements in the WHERE clause, you'd
have to repeat those conditions on all 4 lines.
 
J

Jamie Collins

Douglas said:
Your WHERE clause would look like WHERE Field1 = [Parameter] Or Field2 =
[Parameter] Or Field3 = [Parameter] Or Field4 = [Parameter]. Make sure you
spell the parameter name identically in all 4 cases.

Alternatively (particularly if typing the parameter name is an issue
<g>):

WHERE [Parameter] IN (Field1, Field2, Field3)

Jamie.

--
 
D

Douglas J. Steele

Jamie Collins said:
Your WHERE clause would look like WHERE Field1 = [Parameter] Or Field2 =
[Parameter] Or Field3 = [Parameter] Or Field4 = [Parameter]. Make sure you
spell the parameter name identically in all 4 cases.

Alternatively (particularly if typing the parameter name is an issue
<g>):

WHERE [Parameter] IN (Field1, Field2, Field3)


Clever!

What about field 4 though? <g>
 

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

Top