How can I get a MSAccess macro to stop automatically when I get a primary key violation?
Posted on 2003-03-10
I've written a macro that loads data from a text file into an MSAccess database. The macro is triggered by a command line so the whole process is automatic and requires no user intervention. I've noticed that if I try to load data that creates a primary key violation, an error msg appears on the screen and waits until there is some user intervention to close down the msg box and rollback any previous inserts. This process needs to be automatic. I've had a look at macro conditions and tried to find one that will look for duplicate values of my primary key field and if any occur to rollback and stop the macro. I can't find any suitable conditions my guess at 'IsDuplicate' is not recognised. Does anyone know of a condition or a way to get my macro to stop automatically in such a situation.
I also need to report this error, which I would like to do by moving the file to an /error dir or renaming the file to incorporate the word 'error'. Does anyone know of a command in the macro to move files?