comparing a value to a list

  • Thread starter Comparing field to list to filter
  • Start date
C

Comparing field to list to filter

Trying to filter a report by comparing a field value to a list without having
to retype the table name and field everytime - the following works:
[Payments Applied with Groupings Added]![P/A Mess Code 1
Grouping_Grouping]="Additional Information" or
[Payments Applied with Groupings Added]![P/A Mess Code 1
Grouping_Grouping]=" Bundling/Mod/CPT"

But isn't there a way to compare the table/field name to "additional
information" and "bundling/mod/cpt" without completely reentering the
table/field name everytime. I've tried seperating with semi-colons etc and
can't get the syntax correct.
 
M

Marshall Barton

Comparing field to list to filter <Comparing field to list
to said:
Trying to filter a report by comparing a field value to a list without having
to retype the table name and field everytime - the following works:
[Payments Applied with Groupings Added]![P/A Mess Code 1
Grouping_Grouping]="Additional Information" or
[Payments Applied with Groupings Added]![P/A Mess Code 1
Grouping_Grouping]=" Bundling/Mod/CPT"

But isn't there a way to compare the table/field name to "additional
information" and "bundling/mod/cpt" without completely reentering the
table/field name everytime. I've tried seperating with semi-colons etc and
can't get the syntax correct.


Ahhh, the tedium of long names :)

The typical way to make a query more readable and easier to
type is to use an alias for the table:

SELECT T.*
FROM [Payments Applied with Groupings Added] AS T
WHERE T.[P/A Mess Code 1 Grouping_Grouping] =
"Additional Information"
OR T.[P/A Mess Code 1 Grouping_Grouping] =
" Bundling/Mod/CPT"

But to answer your specific question, you can use the IN
operator:

WHERE T.[P/A Mess Code 1 Grouping_Grouping]
IN("Additional Information", " Bundling/Mod/CPT")
 
Top