Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

import errors and the error object

Status
Not open for further replies.

jeffmoore

Programmer
Aug 29, 2003
301
US
I'm importing data from a csv file in to a table. I've purposfully include an error so that one record will fail to import.
I'm tring to trap the error or some who see the error.
Before the import I clear the errors and then look at the error.count when I'm done importing the data.
the error count remains at 0....
yet I get a table created with the import errors in it.

I the only way to test for this type of error, is to look and see if an error table has been created.
please say theres a better way!!!!!
TIA
 
jeffmoore

Jeff, if you are importing from the menu, or query, my experience has been that you will only see errors in import error table.

If you from code, you have more control.
 
I'm doing it from code.... thats where I'm trying to see the error in the error object.
 
Well - lot of those transfer thingies are more or less just automating the menu thingies, with their inbuilt handling, which is sufficient for lot of purposes.

To get the degree of control it seems you need, I'd consider reading the file through code, perform validation, then insert into tables.

Here are some threads with my favourite method of reading text files (filesystemobject) thread705-840886, thread181-798388, thread705-778800.

If the file contains delimiters, and you're using 2000+ versions, the split function (small sample in the last thread) would give you the "field values", so you can perform the validation you find appropriate.

For the transfer thingies, I don't use them, but don't they provide a message saying there where errors? If not, you could test for the existance of an errortable, then report it to the user.

Roy-Vidar
 
Thanks for the ideas. I guess the simplest way to get what I want is going to be to test for the error table.
This isn't going to be pretty either since the table name (derived by access from the import csv file name) is variable. To try and anticipate every possible error that could occur via some file reading and validation code leave alot to be desired.
So my plan at the moment is to look thru my table names for a table name like '*importerrors*' and then flag the user.
Thanks again for the input.
Jeff
 
Hi

Dim dbs As Database
Dim tdf As TableDef
Set dbs = CurrentDb

' CHECK IF THERE ARE ANY IMPORT ERRORS CREATED
For Each tdf In dbs.TableDefs
If Right(tdf.Name, 12) = "ImportErrors" Then
do whatever
End If
Next

Might work
 
Thanks Ed
That is close to the approach I took. Here is my code:

Function Look_for_Import_Errors()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
For Each obj In dbs.AllTables
If obj.Name Like "*ImportErrors*" Then
Look_for_Import_Errors = "Import Error"
End If
Next obj

End Function

This way I trap all ImportErrors ie:
ImportErrors1 etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top