macro and SQL statements

W

warnett

I read somewhere that an SQL (query) statement cannot be used within a macro.
So does this mean it cannot run a test on a field created within a query.

For example: [turkeys left]![turkey count]=3

where turkeys left is the query, and turkey count is the field created
within the query.

is this why my macro isnt working? If so is there a way around this?

thanks

Jason
 
S

Steve Schapel

Jason

It is not true that "an SQL (query) statement cannot be used within a
macro". There is actually a macro action called RunSQL which can be
used for running action queries.

What is the macro you are using, what actions does it include, and what
is it supposed to do? If you mean you want to use [turkeys
left]![turkey count]=3 as a Condition in your macro, then no, this will
not work. This, incidentally, is not a SQL statement. If 'turkeys
left' is the name of a query, then [turkeys left]![turkey count]=3 is
not really valid syntax for referring to a value in a field in a query,
and Access will not understand what you mean. Even if it was valid
syntax, it wouldn't work, because how is Access supposed to know which
record in the query you are referring to. However, this should work as
a macro Condition...
DLookup("[turkey count]","turkeys left")=3
 

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