Re: Importing Excel, more data type problems

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



If you want to use the first row in the EXCEL file as your field names, then
every cell in that first row for each of the "field names" must have a name
in it; and that name must be the same as the field name in the table into
which you're importing the data, and they must be in the same order as the
fields in the table. If you set the "HasFieldNames" as False in the
TransferSpreadsheet action, it will treat the first EXCEL row as data, and
those first row values do not need to match the table's field names (but
they still must be in the same order).

If your table has an autonumber field in it, and if that field is not the
very last one in the table (in design view, it's the one at the bottom),
then the TransferSpreadsheet will try to import data into that field from
the spreadsheet from the column corresponding in order to that autonumber
field. Move that field to the "end" of the field list for the table if it's
there.


--

Ken Snell
<MS ACCESS MVP>




"James" <James@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B3414F15-BC60-4D50-8CCC-C60DEA6B7307@xxxxxxxxxxxxxxxx
The Excel file I have to import is generated automatically by QuickBooks
so I
have no control over the format, etc., it comes out in. That said, I have
(at least) two problems importing this data.

1) I need to use the first row of Excel data as column names in my
imported
table -- except not all the fields in the first row have data in them. Is
this a potential problem?

To create the necessary table to import the Excel data into, I created a
table ("Imported_RawData") using:

Dim col As ADOX.Column
col.Name = "Field1"
col.Type = adVarWChar
col.DefinedSize = 100
col.Attributes = 0
Set col.ParentCatalog = cat
tbl.Columns.Append col

etc...

I use "Field1", etc., as column names for all the empty fields in the 1st
row of the Excel file, and the text names otherwise. When I run the code
for
creating the table, all looks fine. However...

2) After the 1st row of data in the Excel file, each subsequent field of
each column is itself either blank or text or number or date, etc. And
when
I run the following code, I get a Run-time error '13' type mismatch:

Dim stDocName As String
stDocName = "C:\Data\RawData.xls"
DoCmd.TransferSpreadsheet acImport, "Imported_RawData", stDocName,
True,
"Sheet1$"


The frustrating part of this is that when I manually import the table with
the wizard, the data comes into Access perfectly! But using this manual
import is not an option for the application, unfortunately. Is there a
way
to automate the wizard process in VBA or any other (non-manual) way to get
this data into Access?

Thank you very much for any suggestions!


.



Relevant Pages

  • Re: Importing Excel, more data type problems
    ... <MS ACCESS MVP> ... those first row values do not need to match the table's field names (but ... two problems importing this data. ... row of the Excel file, ...
    (microsoft.public.access.externaldata)
  • Re: Mail Merge
    ... The Excel file I receive is an automated process that I receive every ... Aid Text - FSSL ... first row in the mail merge. ... Row 1- Mack Miller, $10,000 ...
    (microsoft.public.office.misc)
  • Re: Excel Export - Field Names in First Row of Spreadsheet
    ... At the moment I am using TransferSpreadsheet to create the Excel file. ... If I need to include code to open the Excel file (to delete the first row), ... Or use TransferSpreadsheet to export the query, ...
    (microsoft.public.access.externaldata)
  • Text disappears in printing and print preview
    ... I have had a brief look in other posts and can't find the answer. ... get the first little bit of the first row, ... I have checked the cells, they are set to no fill, so it is not an accidental ... It was originally an excel file and I ...
    (microsoft.public.word.tables)
  • Text file, SAP and multi language support problems????
    ... I have been having difficulties for many months now when importing text data ... that is exported from SAP then FTP's from a UNIX server to my SQL server. ... contains 6 columns and the first row contains data only in the first 5 ...
    (microsoft.public.sqlserver.dts)