Run Macro Problems

A

Arnold

I am trying to initiate a Macro from another Macro using
the RunMacro option. However, the problem I am having is
that I want the RunMacro to only run based on a condition.

Basically, I want to run a macro which sends an e-mail of
a specific query, but only if one of the columns in the
query equates to a specific value. I know you can add
True of False conditions to the RunMacro option, but I am
struggling to get it working. An error message keeps
appearing telling me that Access can't find the object i
am referring to. Can anyone help?

Thanks in advance!!!!
 
S

Steve Schapel

Arnold,

Please let us know the Condition expression you have tried so far, and
an example or at least a hint of the data you are using to decide
whether to send the email.
 
A

Arnold

Steve,

Thanks for replying. Basically, we have a query (Query1)
and within that query there is an expression (Expr1)
which calculates a value. When this value is TRUE we want
a macro to send an email to certain persons.
In the macro we are using the SendObject command to send
the email but are having to use a second macro to
initiate this first macro when the expression in the
query is TRUE. In the second macro we are using the
command RunMacro and in the condition box
entering "[Query1]![Expr1 = 'TRUE']", and have also tried
entering the full IF expression which calculates the true
result. Surely this would then mean that when the
expression in the query had the correct value (true) then
it would run the first macro which in turn would send the
email.
When we run this second macro though the error message
says it can't find Query1 and talks about how to put the
expression in the right format in relation to Forms and
Reports. We have also tried running an OpenQuery command
in the second macro then RunMacro with the
expression 'Expr1 = "TRUE"' but the error message says it
still can't find the expression.

Any ideas? If you need more info then please let me know.

Thanks
----Original Message-----
Arnold,

Please let us know the Condition expression you have tried so far, and
an example or at least a hint of the data you are using to decide
whether to send the email.
using the RunMacro option. However, the problem I am
having is that I want the RunMacro to only run based on a
condition.Basically, I want to run a macro which sends an e-mail of
a specific query, but only if one of the columns in the
query equates to a specific value. I know you can add
True of False conditions to the RunMacro option, but I am
struggling to get it working. An error message keeps
appearing telling me that Access can't find the object i
am referring to. Can anyone help?
 
S

Steve Schapel

Arnold,

Thanks for the clarification. Basically, the expression
[Query1]![Expr1] is not valid syntax, and is not understood by Access.
It looks like you mis-typed it, as the ] is in the wrong place. But
even then, it doesn't make sense... you can't refer directly to the
value of a query or table field, which is reasonable when you think
about it, because Access would need to know which record. This applies,
even if the query or table has only one record (as I presume is the case
in your example), because Access doesn't "know" that it will always only
have one record. Therefore you will need to specify the query record
using a Domain Aggregate Function, most likely DLookup() would be
applicable, for example your macro Condition might look like this:
DLookup("[Expr1]","Query1")="TRUE"
 

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