Re: Interrupting a loop with a button click

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: BruceS (BruceS_at_discussions.microsoft.com)
Date: 02/07/05


Date: Sun, 6 Feb 2005 16:49:05 -0800

Thanks, Graham! Worked great!
Bruce

"Graham Mandeno" wrote:

> Hi Bruce
>
> Have the button set a module-level boolean variable to True in its Click
> event procedure. Then the trick is to insert a DoEvents statement in your
> loop, just before you check whether this boolean has been set. That will
> allow any outstanding events (i.e. your Click event) to fire before the code
> continues.
> --
> Good Luck!
>
> Graham Mandeno [Access MVP]
> Auckland, New Zealand
>
> "BruceS" <BruceS@discussions.microsoft.com> wrote in message
> news:BE20C2A9-3806-474B-83FC-46A80B310A3C@microsoft.com...
> > Hi, everyone!
> >
> > [Access 2002]
> > I have a for/next loop that does some serious data manipulation on tables
> > containing many thousands of records. Occasionally, I want it to stop
> > processing after several hundred records have been done to check the
> > results,
> > so I added a "Stop" button to the form to keep me from having to update
> > the
> > code manually to stop after x records are processed. Just before I start
> > the
> > loop, I make the button visible, then turn it off when the loop is
> > finished.
> >
> > I tried using the button to set the loop counter (x) to the "To" value (y)
> > in the "For x = 1 To y" statement. That did not work.
> >
> > Next, I tried creating a global variable that is tested just prior to the
> > "Next x" statement, and set it to False using the button. That didn't
> > work
> > either.
> >
> > It's like clicking the button doesn't update the variable, but if I break
> > into the code, the value is there. (PS: It takes a few seconds for
> > processing to stop when I hit Ctrl+Break.) If I step through the code, it
> > works fine.
> >
> > Does anyone know a neat trick to make this work?
> >
> > Thanks,
> > BruceS
>
>
>



Relevant Pages

  • Re: TextOut() to a DialogBox ???
    ... Do you know the "guard page" trick? ... significant cost of the entire loop. ... So the trick is to put an unreadable page just ... This is a value which tells the stack unwinder what to do, it is itself, not an exception. ...
    (microsoft.public.vc.mfc)
  • Re: An "acceptable" use of break
    ... >trick to perform modular division by 8. ... >neither readable, nor robust. ... better method would be to substitute this loop: ...
    (comp.lang.c)
  • Re: Implementing my own memcpy
    ... and instruction sets that include "decrement and branch if nonzero": ... (The first loop is VAX assembly, ... second loop is 680x0 assembly and uses a special trick in the ... Reading email is like searching for food in the garbage, ...
    (comp.lang.c)
  • Re: how to open remote controller SONY RM-PP411
    ... The trick is to figure out which side is ... the hook and which side is the loop. ... Sometimes they reverse as you go ...
    (sci.electronics.repair)
  • Re: Can you display remaining character space?
    ... That did the trick! ... "John Nurick" wrote: ... > event procedure. ... > Please respond in the newgroup and not by email. ...
    (microsoft.public.access.modulesdaovba)