Log in

View Full Version : problem import tab in excel into access



sakura.saki
07-05-2012, 08:42 AM
Hi guys,
I have the following code which imports one tab which is called "Cor" in an excel sheet into the database, there is no error messege, but somehow after running the code, there is always some more tables created, named as "Cor$_ImportErrors"

any idea how to make it work normal? thanks!
Sub AccessToExcel()
DoCmd.TransferSpreadsheet acImport, 8, "teams CW1", "P:\Fraib\Securities\Sales\status report\access tables to excel.xls", True, "Cor!"
DoCmd.SetWarnings False
DoCmd.Rename "teams CW", acTable, "teams CW1"
DoCmd.SetWarnings True
End Sub

hansup
07-05-2012, 02:11 PM
Examine the information contained in "Cor$_ImportErrors" table. When I've found ImportErrors tables, they include 1 row for each source value whose datatype didn't match that of the destination field. But there may be other types of import errors as well which I haven't encountered.

You may be able to avoid creating the "Cor$_ImportErrors" table if you delete the "teams CW1" table before you run TransferSpreadsheet. Then TransferSpreadsheet can create a fresh version of "teams CW1" whose field types are appropriate for the incoming data.

If you're already doing that, but still get import errors, the explanation may be that Access is guessing incorrectly about field types because it only examines a subset of the incoming data to determine which field types to use. If that is your situation, you can create an import spec to tell Access what data type to use for each of the fields.