Cannot Trap Import Errors in VBA

MEDolin

Registered User.
Local time
Today, 07:30
Joined
Nov 6, 2001
Messages
17
During my import I transfertext all my data into [Table1] that has a [ID] field that I have indexed with "NO" duplicates. If the user trys to import the text file a second time that get the error message "Microsoft Access was unable to append all the data to the table. The contents of 0 records(s) were deleted, and 10 records(s) was lost due to key violations....."

If I add Docmd.Setwarings False the above error message does not show and gives the user the impression that they just imported the file again.

I would like to create a custom error message for this instead of showing the user the above error message.

I found and article on MS Knowledge base (Q197596) that bascially tells me what i already know.

Is there a way to trap this import error?

Thanks for any help!

MD
 
Are you getting an error number? Are you using "On Error goto Err_trap"?
 
Boy, if you figure out a way to do this, I'd sure like to know. The dreaded Key Violation error does not show an error number, so I've never figured out a way to trap it. I've gotten around this (sort of) by writing a "SafeImport" function that does the following:
1. imports stuff first into a temporary table that has no indexes
2. checks the temporary table for duplicates based on the indexes in the destination table.
3. If any duplicates are found,warn the user and move them to a "KVerror" table.
4. Then transfer stuff from the temporary table to the destination table.

If anyone knows of an easier way of handling this, I'd sure be interested!
 

Users who are viewing this thread

Back
Top Bottom