G
Guest
I have a complicated query that is driving me nuts.
Is there any way to keep AND statements together within a single field in
query design? Access is automatically splitting the AND statements into more
than 1 field. Even going into the SQL statement, it is still splitting the
AND statements. I want the query to remain how I design it:
Field 1: ((Like [1] AND B1=X) OR (Not Like [1] AND B1=Y))
Field 2: ((Like [2] AND B2=X) OR (Not Like [2] AND B2=Y))
In 10 different fields total. In design view, each AND statement is on a
different criteria row, to account for the OR
The problem is, Access splits the AND statments for each line out, giving
them their own calculated field, and the query becomes:
(Like [1] AND Like [2] AND B1=X AND B2=X) OR (Not Like [1] AND Not Like [2]
AND B1=Y AND B2=Y)
Which is a totally different criteria from what I designed, and if any 1 of
B1 or B2, etc... = Y at all, then it fails, returning nothing, since it is
looking for Like [1] and Not Like [1] at the same time. It would only return
information filtering out what I want, if I make every B1, B2, etc... = Y.
Going into the SQL statement and manually arranging the AND / OR statements
the way I want, keeps the statements that way IN SQL VIEW, but still splits
them in design view, and treats it exactly like splitting it under run-time.
Is there any way to keep AND statements together within a single field in
query design? Access is automatically splitting the AND statements into more
than 1 field. Even going into the SQL statement, it is still splitting the
AND statements. I want the query to remain how I design it:
Field 1: ((Like [1] AND B1=X) OR (Not Like [1] AND B1=Y))
Field 2: ((Like [2] AND B2=X) OR (Not Like [2] AND B2=Y))
In 10 different fields total. In design view, each AND statement is on a
different criteria row, to account for the OR
The problem is, Access splits the AND statments for each line out, giving
them their own calculated field, and the query becomes:
(Like [1] AND Like [2] AND B1=X AND B2=X) OR (Not Like [1] AND Not Like [2]
AND B1=Y AND B2=Y)
Which is a totally different criteria from what I designed, and if any 1 of
B1 or B2, etc... = Y at all, then it fails, returning nothing, since it is
looking for Like [1] and Not Like [1] at the same time. It would only return
information filtering out what I want, if I make every B1, B2, etc... = Y.
Going into the SQL statement and manually arranging the AND / OR statements
the way I want, keeps the statements that way IN SQL VIEW, but still splits
them in design view, and treats it exactly like splitting it under run-time.