building in an abort function

  • Thread starter Thread starter Louis
  • Start date Start date
L

Louis

Hi

I have an online backend sql database with access frontend. I have a form
function that imports certain data into the mdb file when necessary. The
import process is a function that build lots of INSERT statements and
executes them in ADO. Once the process starts it is impossible to stop it
until it is complete - without quitting the program. Is there a way to
build in a stop activity button that is still available when a process
starts.

Thanks

AL
 
Louis,

Yes, you can do this.

Generally, I have a command button that kicks off the
import. When the user presses the command button, I
change its caption to "Cancel", and set its Tag property
to 0. When the user presses the command button again, I
set its Tag property to 1.

Then, just before I do the next import, I check to see
whether that controls tag property = 1. If it is equal to
1, then I goto my exit procedure, which includes code to
change the caption back to "Import" and the Tag property
back to 0. I also close any recordsets or other objects
that were opened during the import.

If you are doing all of this inside a loop, I would also
include a DoEvents command to allow to perform other
Windows functions while this import is taking place.

If you are going to do this, you need to also consider
using transaction processing code that would allow you to
rollback the transactions if you cancel the import.

HTH
Dale
 
Back
Top