dbTalk Databases Forums  

Importing From Excel - Access Create Wrong Data Type

comp.database.ms-access comp.database.ms-access


Discuss Importing From Excel - Access Create Wrong Data Type in the comp.database.ms-access forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Alan B. Densky
 
Posts: n/a

Default Importing From Excel - Access Create Wrong Data Type - 03-08-2007 , 08:27 PM






In Excel, any cell can contain any data, and the data may or may not be
formatted in a particular way. In Access, by contrast, every field has a
fixed data type and can only contain a value of that type ( double,
text, etc.). When Access imports from Excel to a new table, it guesses
the field types to use by examining the data in the first few rows of
the Excel table - and often gets it wrong. This can cause Access to bomb
out during the import.

The "Fix" for this - according to another post, is to massage the data in
the import. That is riciculous.

Does anyone have a way to fix this problem the right way?

Alan






Reply With Quote
  #2  
Old   
Rick Brandt
 
Posts: n/a

Default Re: Importing From Excel - Access Create Wrong Data Type - 03-08-2007 , 09:27 PM






Alan B. Densky wrote:
Quote:
In Excel, any cell can contain any data, and the data may or may not
be formatted in a particular way. In Access, by contrast, every field
has a fixed data type and can only contain a value of that type (
double, text, etc.). When Access imports from Excel to a new table,
it guesses the field types to use by examining the data in the first
few rows of the Excel table - and often gets it wrong. This can
cause Access to bomb out during the import.

The "Fix" for this - according to another post, is to massage the
data in the import. That is riciculous.

Does anyone have a way to fix this problem the right way?
Whenever I am importing from a source that does not have explicit DataTypes I
always first import into a table having all text fields. Then I can run an
append query from that table into the final one using the appropriate formulas
to convert the data. At least then you are in total control and can examine the
rows that have problems to see what is going on.


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com




Reply With Quote
  #3  
Old   
Alan B. Densky
 
Posts: n/a

Default Re: Importing From Excel - Access Create Wrong Data Type - 03-08-2007 , 10:48 PM



Hi Rick,

All of the fields in my Access DB are already text fields.

My problem is that Access, in it's infinate wisdom, is assigning data types
to the columns in the linked spreadsheet based on the data in the first few
records. So, for instance, if I have a zip code column in the Excel spread
sheet, and the first several records don't have a hypnen and zip + 4, and
several rows later some of the zips have a hyphen 33063-1234, the import
bombs because Access has assigned the data type of Number to the link on
that column. And what you see in the link is #num.

In addition, if the zip code has a leading zero (01234), because it's a
number column, it strips out the leading zero. I have similar problems on
several other fields.

So I need some way to tell Access to force all of the columns in the link to
be Text data type.

Alan


"Rick Brandt" <rickbrandt2 (AT) hotmail (DOT) com> wrote

Quote:
Alan B. Densky wrote:
In Excel, any cell can contain any data, and the data may or may not
be formatted in a particular way. In Access, by contrast, every field
has a fixed data type and can only contain a value of that type (
double, text, etc.). When Access imports from Excel to a new table,
it guesses the field types to use by examining the data in the first
few rows of the Excel table - and often gets it wrong. This can
cause Access to bomb out during the import.

The "Fix" for this - according to another post, is to massage the
data in the import. That is riciculous.

Does anyone have a way to fix this problem the right way?

Whenever I am importing from a source that does not have explicit
DataTypes I always first import into a table having all text fields. Then
I can run an append query from that table into the final one using the
appropriate formulas to convert the data. At least then you are in total
control and can examine the rows that have problems to see what is going
on.


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com





Reply With Quote
  #4  
Old   
Rick Brandt
 
Posts: n/a

Default Re: Importing From Excel - Access Create Wrong Data Type - 03-08-2007 , 10:57 PM



Alan B. Densky wrote:
Quote:
Hi Rick,

All of the fields in my Access DB are already text fields.

My problem is that Access, in it's infinate wisdom, is assigning data
types to the columns in the linked spreadsheet based on the data in
the first few records. So, for instance, if I have a zip code column
in the Excel spread sheet, and the first several records don't have a
hypnen and zip + 4, and several rows later some of the zips have a
hyphen 33063-1234, the import bombs because Access has assigned the
data type of Number to the link on that column. And what you see in
the link is #num.
In addition, if the zip code has a leading zero (01234), because it's
a number column, it strips out the leading zero. I have similar
problems on several other fields.

So I need some way to tell Access to force all of the columns in the
link to be Text data type.
I never link to Excel. Only import. For exactly this reason.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com




Reply With Quote
  #5  
Old   
John Nurick
 
Posts: n/a

Default Re: Importing From Excel - Access Create Wrong Data Type - 03-09-2007 , 01:26 AM



Hi Alan,

See
http://www.dicks-blog.com/archives/2...ed-data-types/
and http://support.microsoft.com/?id=257819
and
http://msdn.microsoft.com/library/de...ess_driver.asp
and http://office.microsoft.com/en-us/ac...950951033.aspx


Also, consider upgrading to Access 2007, which offers more direct
control.


On Thu, 8 Mar 2007 20:27:31 -0500, "Alan B. Densky"
<AlanD (AT) neuro-vision (DOT) us> wrote:

Quote:
In Excel, any cell can contain any data, and the data may or may not be
formatted in a particular way. In Access, by contrast, every field has a
fixed data type and can only contain a value of that type ( double,
text, etc.). When Access imports from Excel to a new table, it guesses
the field types to use by examining the data in the first few rows of
the Excel table - and often gets it wrong. This can cause Access to bomb
out during the import.

The "Fix" for this - according to another post, is to massage the data in
the import. That is riciculous.

Does anyone have a way to fix this problem the right way?

Alan




--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.


Reply With Quote
  #6  
Old   
Alan B. Densky
 
Posts: n/a

Default Re: Importing From Excel - Access Create Wrong Data Type - 03-14-2007 , 09:07 PM



Hi John,

Thanks for the effort. I had the link to www.disks-blog and went through
that information a while back. It didn't help because it just didn't make
any difference when I edited the registry.

As far a Acess 2007 - I have no interest in spending the money, upgrading,
or going through the learning curve.

My database is based on DAO, so the ADO isn't going to help me, and I don't
want to go through the learning curve. I quit programming for money a couple
of years ago, and now only program for my own business and a few old
customers. I don't have the time, energy, or desire to play the Microsoft
"learn to do it our way, and we'll make make your learning investment
obsolete whenever we feel like it" game any longer. Especially since so many
people are sending their work to Rent-A-Coder people for $5.00 a day.

Is there any other way around this issue? Maybe I'm just going to have to
break down and do an import of a CSV file in a temp table?? It sounds like
my only work-around that I don't have to go through a learning curve to
accomplish. Unless you know of some other way to trick Access to look at all
of my linked columns for this particular table as Text columns.

Thanks again,

Alan

"John Nurick" <j.mapSoN.nurick (AT) dial (DOT) pipex.com> wrote

Quote:
Hi Alan,

See
http://www.dicks-blog.com/archives/2...ed-data-types/
and http://support.microsoft.com/?id=257819
and
http://msdn.microsoft.com/library/de...ess_driver.asp
and http://office.microsoft.com/en-us/ac...950951033.aspx


Also, consider upgrading to Access 2007, which offers more direct
control.


On Thu, 8 Mar 2007 20:27:31 -0500, "Alan B. Densky"
AlanD (AT) neuro-vision (DOT) us> wrote:

In Excel, any cell can contain any data, and the data may or may not be
formatted in a particular way. In Access, by contrast, every field has a
fixed data type and can only contain a value of that type ( double,
text, etc.). When Access imports from Excel to a new table, it guesses
the field types to use by examining the data in the first few rows of
the Excel table - and often gets it wrong. This can cause Access to bomb
out during the import.

The "Fix" for this - according to another post, is to massage the data in
the import. That is riciculous.

Does anyone have a way to fix this problem the right way?

Alan





--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.



Reply With Quote
  #7  
Old   
John Nurick
 
Posts: n/a

Default Re: Importing From Excel - Access Create Wrong Data Type - 03-15-2007 , 02:15 AM



Have you tried using IMEX=1 (which seems to work equally in DAO and
ADO)? E.g.

SELECT * FROM
[Excel 8.0;HDR=Yes;IMEX=1;database=C:\folder\file.xls;].[sheet1$];

On Wed, 14 Mar 2007 21:07:24 -0400, "Alan B. Densky"
<AlanD (AT) neuro-vision (DOT) us> wrote:

Quote:
Hi John,

Thanks for the effort. I had the link to www.disks-blog and went through
that information a while back. It didn't help because it just didn't make
any difference when I edited the registry.

As far a Acess 2007 - I have no interest in spending the money, upgrading,
or going through the learning curve.

My database is based on DAO, so the ADO isn't going to help me, and I don't
want to go through the learning curve. I quit programming for money a couple
of years ago, and now only program for my own business and a few old
customers. I don't have the time, energy, or desire to play the Microsoft
"learn to do it our way, and we'll make make your learning investment
obsolete whenever we feel like it" game any longer. Especially since so many
people are sending their work to Rent-A-Coder people for $5.00 a day.

Is there any other way around this issue? Maybe I'm just going to have to
break down and do an import of a CSV file in a temp table?? It sounds like
my only work-around that I don't have to go through a learning curve to
accomplish. Unless you know of some other way to trick Access to look at all
of my linked columns for this particular table as Text columns.

Thanks again,

Alan

"John Nurick" <j.mapSoN.nurick (AT) dial (DOT) pipex.com> wrote in message
news:u1v1v2d2pa9bohnush8o3imbp8l6kpefjg (AT) 4ax (DOT) com...
Hi Alan,

See
http://www.dicks-blog.com/archives/2...ed-data-types/
and http://support.microsoft.com/?id=257819
and
http://msdn.microsoft.com/library/de...ess_driver.asp
and http://office.microsoft.com/en-us/ac...950951033.aspx


Also, consider upgrading to Access 2007, which offers more direct
control.


On Thu, 8 Mar 2007 20:27:31 -0500, "Alan B. Densky"
AlanD (AT) neuro-vision (DOT) us> wrote:

In Excel, any cell can contain any data, and the data may or may not be
formatted in a particular way. In Access, by contrast, every field has a
fixed data type and can only contain a value of that type ( double,
text, etc.). When Access imports from Excel to a new table, it guesses
the field types to use by examining the data in the first few rows of
the Excel table - and often gets it wrong. This can cause Access to bomb
out during the import.

The "Fix" for this - according to another post, is to massage the data in
the import. That is riciculous.

Does anyone have a way to fix this problem the right way?

Alan





--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.

--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.


Reply With Quote
  #8  
Old   
Alan B. Densky
 
Posts: n/a

Default Re: Importing From Excel - Access Create Wrong Data Type - 03-15-2007 , 07:40 PM



Hi John,

How would I go about using that? Currently I'm using TransferSpreadsheet to
create my link to my spreadsheet.

DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, "tblLeads",
YesDB, False

Alan

"John Nurick" <j.mapSoN.nurick (AT) dial (DOT) pipex.com> wrote

Quote:
Have you tried using IMEX=1 (which seems to work equally in DAO and
ADO)? E.g.

SELECT * FROM
[Excel 8.0;HDR=Yes;IMEX=1;database=C:\folder\file.xls;].[sheet1$];

On Wed, 14 Mar 2007 21:07:24 -0400, "Alan B. Densky"
AlanD (AT) neuro-vision (DOT) us> wrote:

Hi John,

Thanks for the effort. I had the link to www.disks-blog and went through
that information a while back. It didn't help because it just didn't make
any difference when I edited the registry.

As far a Acess 2007 - I have no interest in spending the money, upgrading,
or going through the learning curve.

My database is based on DAO, so the ADO isn't going to help me, and I
don't
want to go through the learning curve. I quit programming for money a
couple
of years ago, and now only program for my own business and a few old
customers. I don't have the time, energy, or desire to play the Microsoft
"learn to do it our way, and we'll make make your learning investment
obsolete whenever we feel like it" game any longer. Especially since so
many
people are sending their work to Rent-A-Coder people for $5.00 a day.

Is there any other way around this issue? Maybe I'm just going to have to
break down and do an import of a CSV file in a temp table?? It sounds like
my only work-around that I don't have to go through a learning curve to
accomplish. Unless you know of some other way to trick Access to look at
all
of my linked columns for this particular table as Text columns.

Thanks again,

Alan

"John Nurick" <j.mapSoN.nurick (AT) dial (DOT) pipex.com> wrote in message
news:u1v1v2d2pa9bohnush8o3imbp8l6kpefjg (AT) 4ax (DOT) com...
Hi Alan,

See
http://www.dicks-blog.com/archives/2...ed-data-types/
and http://support.microsoft.com/?id=257819
and
http://msdn.microsoft.com/library/de...ess_driver.asp
and http://office.microsoft.com/en-us/ac...950951033.aspx


Also, consider upgrading to Access 2007, which offers more direct
control.


On Thu, 8 Mar 2007 20:27:31 -0500, "Alan B. Densky"
AlanD (AT) neuro-vision (DOT) us> wrote:

In Excel, any cell can contain any data, and the data may or may not be
formatted in a particular way. In Access, by contrast, every field has a
fixed data type and can only contain a value of that type ( double,
text, etc.). When Access imports from Excel to a new table, it guesses
the field types to use by examining the data in the first few rows of
the Excel table - and often gets it wrong. This can cause Access to
bomb
out during the import.

The "Fix" for this - according to another post, is to massage the data
in
the import. That is riciculous.

Does anyone have a way to fix this problem the right way?

Alan





--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.


--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.



Reply With Quote
  #9  
Old   
John Nurick
 
Posts: n/a

Default Re: Importing From Excel - Access Create Wrong Data Type - 03-16-2007 , 02:24 AM



Just create a new query, switch to SQL View, and paste the SELECT...
statement into the window. Then modify it to suit your filename and
sheet name so it delivers the data you need, and save it. After that you
can use it pretty much as if it were a linked table.

On Thu, 15 Mar 2007 19:40:22 -0400, "Alan B. Densky"
<AlanD (AT) neuro-vision (DOT) us> wrote:

Quote:
Hi John,

How would I go about using that? Currently I'm using TransferSpreadsheet to
create my link to my spreadsheet.

DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, "tblLeads",
YesDB, False

Alan

"John Nurick" <j.mapSoN.nurick (AT) dial (DOT) pipex.com> wrote in message
news:e2phv2td1srev6hd7k2cmf6jpnbibri4ng (AT) 4ax (DOT) com...
Have you tried using IMEX=1 (which seems to work equally in DAO and
ADO)? E.g.

SELECT * FROM
[Excel 8.0;HDR=Yes;IMEX=1;database=C:\folder\file.xls;].[sheet1$];

On Wed, 14 Mar 2007 21:07:24 -0400, "Alan B. Densky"
AlanD (AT) neuro-vision (DOT) us> wrote:

Hi John,

Thanks for the effort. I had the link to www.disks-blog and went through
that information a while back. It didn't help because it just didn't make
any difference when I edited the registry.

As far a Acess 2007 - I have no interest in spending the money, upgrading,
or going through the learning curve.

My database is based on DAO, so the ADO isn't going to help me, and I
don't
want to go through the learning curve. I quit programming for money a
couple
of years ago, and now only program for my own business and a few old
customers. I don't have the time, energy, or desire to play the Microsoft
"learn to do it our way, and we'll make make your learning investment
obsolete whenever we feel like it" game any longer. Especially since so
many
people are sending their work to Rent-A-Coder people for $5.00 a day.

Is there any other way around this issue? Maybe I'm just going to have to
break down and do an import of a CSV file in a temp table?? It sounds like
my only work-around that I don't have to go through a learning curve to
accomplish. Unless you know of some other way to trick Access to look at
all
of my linked columns for this particular table as Text columns.

Thanks again,

Alan

"John Nurick" <j.mapSoN.nurick (AT) dial (DOT) pipex.com> wrote in message
news:u1v1v2d2pa9bohnush8o3imbp8l6kpefjg (AT) 4ax (DOT) com...
Hi Alan,

See
http://www.dicks-blog.com/archives/2...ed-data-types/
and http://support.microsoft.com/?id=257819
and
http://msdn.microsoft.com/library/de...ess_driver.asp
and http://office.microsoft.com/en-us/ac...950951033.aspx


Also, consider upgrading to Access 2007, which offers more direct
control.


On Thu, 8 Mar 2007 20:27:31 -0500, "Alan B. Densky"
AlanD (AT) neuro-vision (DOT) us> wrote:

In Excel, any cell can contain any data, and the data may or may not be
formatted in a particular way. In Access, by contrast, every field has a
fixed data type and can only contain a value of that type ( double,
text, etc.). When Access imports from Excel to a new table, it guesses
the field types to use by examining the data in the first few rows of
the Excel table - and often gets it wrong. This can cause Access to
bomb
out during the import.

The "Fix" for this - according to another post, is to massage the data
in
the import. That is riciculous.

Does anyone have a way to fix this problem the right way?

Alan





--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.


--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.

--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.


Reply With Quote
  #10  
Old   
Alan B. Densky
 
Posts: n/a

Default Re: Importing From Excel - Access Create Wrong Data Type - 03-17-2007 , 08:39 AM



Thanks John.
"John Nurick" <j.mapSoN.nurick (AT) dial (DOT) pipex.com> wrote

Quote:
Just create a new query, switch to SQL View, and paste the SELECT...
statement into the window. Then modify it to suit your filename and
sheet name so it delivers the data you need, and save it. After that you
can use it pretty much as if it were a linked table.

On Thu, 15 Mar 2007 19:40:22 -0400, "Alan B. Densky"
AlanD (AT) neuro-vision (DOT) us> wrote:

Hi John,

How would I go about using that? Currently I'm using TransferSpreadsheet
to
create my link to my spreadsheet.

DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, "tblLeads",
YesDB, False

Alan

"John Nurick" <j.mapSoN.nurick (AT) dial (DOT) pipex.com> wrote in message
news:e2phv2td1srev6hd7k2cmf6jpnbibri4ng (AT) 4ax (DOT) com...
Have you tried using IMEX=1 (which seems to work equally in DAO and
ADO)? E.g.

SELECT * FROM
[Excel 8.0;HDR=Yes;IMEX=1;database=C:\folder\file.xls;].[sheet1$];

On Wed, 14 Mar 2007 21:07:24 -0400, "Alan B. Densky"
AlanD (AT) neuro-vision (DOT) us> wrote:

Hi John,

Thanks for the effort. I had the link to www.disks-blog and went through
that information a while back. It didn't help because it just didn't
make
any difference when I edited the registry.

As far a Acess 2007 - I have no interest in spending the money,
upgrading,
or going through the learning curve.

My database is based on DAO, so the ADO isn't going to help me, and I
don't
want to go through the learning curve. I quit programming for money a
couple
of years ago, and now only program for my own business and a few old
customers. I don't have the time, energy, or desire to play the
Microsoft
"learn to do it our way, and we'll make make your learning investment
obsolete whenever we feel like it" game any longer. Especially since so
many
people are sending their work to Rent-A-Coder people for $5.00 a day.

Is there any other way around this issue? Maybe I'm just going to have
to
break down and do an import of a CSV file in a temp table?? It sounds
like
my only work-around that I don't have to go through a learning curve to
accomplish. Unless you know of some other way to trick Access to look at
all
of my linked columns for this particular table as Text columns.

Thanks again,

Alan

"John Nurick" <j.mapSoN.nurick (AT) dial (DOT) pipex.com> wrote in message
news:u1v1v2d2pa9bohnush8o3imbp8l6kpefjg (AT) 4ax (DOT) com...
Hi Alan,

See
http://www.dicks-blog.com/archives/2...ed-data-types/
and http://support.microsoft.com/?id=257819
and
http://msdn.microsoft.com/library/de...ess_driver.asp
and http://office.microsoft.com/en-us/ac...950951033.aspx


Also, consider upgrading to Access 2007, which offers more direct
control.


On Thu, 8 Mar 2007 20:27:31 -0500, "Alan B. Densky"
AlanD (AT) neuro-vision (DOT) us> wrote:

In Excel, any cell can contain any data, and the data may or may not
be
formatted in a particular way. In Access, by contrast, every field has
a
fixed data type and can only contain a value of that type ( double,
text, etc.). When Access imports from Excel to a new table, it guesses
the field types to use by examining the data in the first few rows of
the Excel table - and often gets it wrong. This can cause Access to
bomb
out during the import.

The "Fix" for this - according to another post, is to massage the data
in
the import. That is riciculous.

Does anyone have a way to fix this problem the right way?

Alan





--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.


--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.


--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.