John said:
Try this comparison
If QDF.SQL like "*Into *" & TableName & "*"
AND NOT Qdf.SQL LIKE "*FROM *" & TableName & "*"
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
In:
http://groups.google.com/group/microsoft.public.access/msg/b342e061be8585a1
KenSheridan said:
"Note how each Boolean OR operation is contained in parentheses to force
it to evaluate independently of the Boolean AND operation."
That's very good advice. That statement applies even more if you're
talking about the LIKE operator.
From the A97 Help file (Operator Precedence):
"When several operations occur in an expression, each part is evaluated
and resolved in a predetermined order called operator precedence.
When expressions contain operators from more than one category,
arithmetic operators are evaluated first, comparison operators are
evaluated next, and logical operators are evaluated last. Comparison
operators all have equal precedence; that is, they are evaluated in the
left-to-right order in which they appear. Arithmetic and logical
operators are evaluated in the following order of precedence:
Arithmetic Comparison Logical
Exponentiation (^) Equality (=) Not
Negation (–) Inequality (<>) And
Multiplication and division (*, /) Less than (<) Or
Integer division (\) Greater than (>) Xor
Modulus arithmetic (Mod) Less than or equal to (<=) Eqv
Addition and subtraction (+, –)Greater than or equal to (>=) Imp
String concatenation (&) Like
Is
When multiplication and division occur together in an expression, each
operation is evaluated as it occurs from left to right. When addition
and subtraction occur together in an expression, each operation is
evaluated in order of appearance from left to right. Parentheses can be
used to override the order of precedence and force some parts of an
expression to be evaluated before others. Operations within parentheses
are always performed before those outside. Within parentheses, however,
operator precedence is maintained.
The string concatenation operator (&) is not an arithmetic operator, but
in precedence, it does follow all arithmetic operators and precede all
comparison operators. The Like operator is equal in precedence to all
comparison operators, but is actually a pattern-matching operator. The
Is operator is an object reference comparison operator. It does not
compare objects or their values; it checks only to determine if two
object references refer to the same object."
Since the LIKE operator is near the bottom of the precedence order, if
you have something similar to:
WHERE [SomeField] LIKE "*something*" AND [AnotherField] = "else"
it's very possible for SQL to try to treat that as:
WHERE [SomeField] LIKE ("*something*" AND [AnotherField] = "else")
which can get very confusing if SQL tries to convert "*something*" into
a Boolean and then tries to covert the Boolean result of the AND into a
string. I have not tested out how SQL deals with such things,
preferring to obviate the potential problem, so the potential problem
might not even exist
. I always put LIKE expressions in their own
set of parentheses.
James A. Fortune
(e-mail address removed)