The VBA program has a For…Next loop that takes a long time to execute, and I wanted to provide a way to interrupt the execution. So I changed the command button that initiates the loop into a toggle button, and used its Click event to initiate the loop. Then I tested for for the state of the Toggle button within the loop:
IF tglDoIt.Value = False Then Exit Sub
Works fine for initiating the loop, but when I click the Toggle button as the code is executing (the loop includes DoEvents), Access issues the following error message:
the macro of function set to the beforeupdate or validationRule property for this field is preventing …
There is nothing in BeforeUpdate nor is there a validationRule. The Toggle button is unbound.
Not sure exactly why the message appears… perhaps not being allowed to re-start the routine before it has properly finished the first time? So I changed the control back to a command button, and used its Caption to indicate whether the loop was running or not. However, I felt it was an awkward workaround, and wondered whether there is a way to use a Toggle button to initiate and interrupt a loop without receiving the Access error message?