PC Review


Reply
Thread Tools Rate Thread

Cancel Event for no data in Macro?

 
 
sonofroy
Guest
Posts: n/a
 
      18th Aug 2009
I have a Macro that is running a query and then emails the report associate
to a person. I would like to see if it is possible to cancel this event if no
records are returned in the query? THanks
 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      18th Aug 2009
Sonofroy,

You can use a Condition in your macro like this:
DCount("*","NameOfQuery")>0
This means the macro will nony run if there are records returned by the
query. "NameOfQuery" refers to the name of the query that the report is
based on. I am not sure what exactly you mean by "running a query" in your
original question, but assuming this is an action query, that this is not
the query I am referring to, I mean the Record Source of the report.

--
Steve Schapel, Microsoft Access MVP


"sonofroy" <(E-Mail Removed)> wrote in message
news:51317D5B-AC3F-42B0-BF2D-(E-Mail Removed)...
> I have a Macro that is running a query and then emails the report
> associate
> to a person. I would like to see if it is possible to cancel this event if
> no
> records are returned in the query? THanks


 
Reply With Quote
 
sonofroy
Guest
Posts: n/a
 
      19th Aug 2009
Yes the first step in the Macro is to run an action query and the next step
is to send a report by email. I wanted to stop the macro completely if the
before the email if the action returns no results.


"Steve Schapel" wrote:

> Sonofroy,
>
> You can use a Condition in your macro like this:
> DCount("*","NameOfQuery")>0
> This means the macro will nony run if there are records returned by the
> query. "NameOfQuery" refers to the name of the query that the report is
> based on. I am not sure what exactly you mean by "running a query" in your
> original question, but assuming this is an action query, that this is not
> the query I am referring to, I mean the Record Source of the report.
>
> --
> Steve Schapel, Microsoft Access MVP
>
>
> "sonofroy" <(E-Mail Removed)> wrote in message
> news:51317D5B-AC3F-42B0-BF2D-(E-Mail Removed)...
> > I have a Macro that is running a query and then emails the report
> > associate
> > to a person. I would like to see if it is possible to cancel this event if
> > no
> > records are returned in the query? THanks

>
>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      20th Aug 2009
Sonofroy,

Ok, that's fine. Well, my earlier reply is applicable. Use what I showed
you as the Condition for the first action in the macro after the OpenQuery,
and then put ellipsis (...) in the Condition for all actions after that.

An alternative approach would be to put like this in the Condition:
DCount("*","NameOfQuery")=0
.... and put this for a StopMacro action, straight after the OpenQuery.

As I said before, substitute the actual name of the query for my
"NameOfQuery", but this is not the action query, it is the query the report
is based on.

Make sense?

--
Steve Schapel, Microsoft Access MVP


"sonofroy" <(E-Mail Removed)> wrote in message
news:2DA26786-D7F9-41D7-BCBD-(E-Mail Removed)...
> Yes the first step in the Macro is to run an action query and the next
> step
> is to send a report by email. I wanted to stop the macro completely if the
> before the email if the action returns no results.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Error event : e.cancel operation. NetNewbie Microsoft VB .NET 2 19th Feb 2009 04:49 PM
How to Cancel a Cancel Button event Eric T. Microsoft Dot NET Framework Forms 3 5th Feb 2009 11:36 PM
cancel event if data change Andy Microsoft Access Form Coding 7 1st Dec 2007 05:49 PM
CancelEventArgs.Cancel - How Event Raising Code Know if Client Set .Cancel=true Smithers Microsoft C# .NET 3 24th Sep 2007 02:30 AM
Cancel Macro is user selects 'cancel' at save menu =?Utf-8?B?TWFyaw==?= Microsoft Excel Programming 1 6th Apr 2005 05:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:42 AM.