A family of Microsoft relational database management systems designed for ease of use.
I gave up and put another button on the form. So now there are two: one to Start and another to Stop.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a form that runs a long process processing the records in a table and occasionally write one to the form.
I want to have a single button for starting/stopping the process. I tried putting a button on the form with a label of "Start". When pressed the process starts and the label on the form is changed to Stop. Start works fine. The label is changed to Stop and the process begins running. The first problem is that the click event is not triggered until the process updates the form. The second problem is if the button is clicked multiple times the multiple clicks are stored. If the button is clicked twice the label changes from Stop to Start and then changes back to Stop and the code under the Start processing is run again.
The first question is how to have the click event run its code immediately. The second question is how to prevent multiple clicks from being stacked up and processed.
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
I gave up and put another button on the form. So now there are two: one to Start and another to Stop.
There are two boxes that display status. One has the number of items processed and the other has the number of items to go. However, they are on the main form. Having one form makes it easier for the user. Unfortunately, making it easier for the user makes it harder for me.
Hi Saberman,
As far as I know now, it is not important on which form then Stop-button is placed, only that the form is updated from time to time from "inside" the loop.
So, on the main form you could also place the Stop-button.
Pressing the Stop-button sets a global variable (I named it "active_stop"). When processcontrol is back in the loop, check for the value of "active_stop" and exit the loop depending on its value.
If you don't like globals, you could use a hidden control to hold the value, and the loop inspects that control to exit or to continue.
Imb.
>About your second question; in my example the Start and Stop functionality are separate.
Came to the same conclusion.
>In the same time you can use this Stop-form as "Busy-form" showing a progress bar.
There is another post of mine that shows the form. There are two boxes that display status. One has the number of items processed and the other has the number of items to go. However, they are on the main form. Having one form makes it easier for the user. Unfortunately, making it easier for the user makes it harder for me.
Can you show us the code behind the button
The first question is how to have the click event run its code immediately. The second question is how to prevent multiple clicks from being stacked up and processed.
Hi Saberman,
To give an answer to your first question: interrupt the loop that is processing the records. In your case you have that possibility when you update the form.
In the looping process you can include a kind of Stop-form with the Stop-button, that automatically closes after some time to continue the loop. Pressing the Stop-button exits the loop. But this is quite time-consuming.
To reduce this loss of time, you can use a counter, and only display the Stop-form after so many cycles. Mostly I use about 1% of the total needed cycles.
In the same time you can use this Stop-form as "Busy-form" showing a progress bar. Depending on the kind of the loop, and the kind of the information, I have the choice form many different progress bars.
You see the Busy-form with the Stop-button.
This Busy-form monitors the progress of an analyses of the code in different Access-applications. "Balance" is now underway, still 111 applications to go, with an expected needed time of 27:22, so about 15 seconds per application.
Pressing the Stop-button does not stop the process immediately, but only after update of the Busy-form, so within 15 seconds in the above example.
About your second question; in my example the Start and Stop functionality are separated. The Stop button is on the Busy-form, that is in dialog-mode. No way to press Start again, only after finishing the process loop or pressing the Stop butten.
As an addendum: I made a kind of object of a "Running loop" that is shared by all application, so it is available in every application for any loop.
Imb.