Re: Interrupting a loop with a button click
From: BruceS (BruceS_at_discussions.microsoft.com)
Date: 02/07/05
- Next message: Jamie Pittman via AccessMonster.com: "Re: Make a form to control the query to produce a report."
- Previous message: Rolf Rosenquist: "Properties of sub forms"
- In reply to: Graham Mandeno: "Re: Interrupting a loop with a button click"
- Messages sorted by: [ date ] [ thread ]
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
>
>
>
- Next message: Jamie Pittman via AccessMonster.com: "Re: Make a form to control the query to produce a report."
- Previous message: Rolf Rosenquist: "Properties of sub forms"
- In reply to: Graham Mandeno: "Re: Interrupting a loop with a button click"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|