importing numbers as text

M

Martin Lord

I'm trying to import a 5,000 plus record file into
access. The first field is the part number which can be
pure text, pure numbers or a combination of text and
number. So I'm importing it to a text field. The problem
is that those which are pure number are exported like
this. Part number: "1113276" is imported to access
as: "1.11328e+006".

So I'm having trouble with my queries since the other
files in the database have the original "1113276" value.

How can I force Access to import it as all text? . . .

Thanks!!
 
J

Joe Fallon

Not enough info.
What kind of file are you importing from?
Text, Excel, other?

If Excel, then try putting a text value in the first row of data and see if
that helps.
 
M

Martin Lord

I'm importing it from an excel file. I already defined
the whole row as text by right clicking on the "A"
column, format cells, Category, Text. I import it to
access by using the import spreadsheet wizard. At step 4
of the import wizard in Field Options it recognizes the
partNumber field as text because by default it says: Data
Type: Text. But when I go ahead and finish importing it
still converts these numbers to the numerical value in
scientific notation.

The fields that are a combination of text and number or
just text are imported correctly.

Thanks.

ML
 
J

Joe Fallon

Defining a column in Excel as text using Format cells does not help.

Here is my std advice - give it a try and see if it helps.

Since Excel is not a database, using "mixed" data types in a column causes a
problem when Access has to "guess" which one to use. Access examines the
first 15 rows (or so) and makes a guess. If you want to "force" Access to
guess a text data type then make the first entry in that column a text
value. The reason you get errors is that the first 15 rows are all numeric
and then the text data shows up after Access has already guessed the data
type to be Numeric.

The way to make a text value in your data of numbers is to include a
character!
e.g. 123A

========================================================
==============================
Check your registry settings. The relevant registry keys (for Jet 4.0)
are in:

Hkey_Local_Machine/Software/Microsoft/Jet/4.0/Engines/Excel/

The ImportMixedTypes registry key is always read. You can test this by
changing the key to ImportMixedTypes=OneDayWhen and trying to use the
ISAM: you get the error, 'Invalid setting in Excel key of the Engines
section of the Windows Registry.' The only valid values are:

ImportMixedTypes=Text
ImportMixedTypes=Majority Type

Data type is determined column by column.

ImportMixedTypes='Majority Type' means a certain number of rows (more
on this later) in each column are scanned and the data types are
counted. Both a cell's value and format are used to determine data
type. The majority data type (i.e. the one with the most rows) decides
the overall data type for the entire column. There's a bias in favor
of numeric in the event of a tie. Rows from any minority data types
found that can't be cast as the majority data type will be returned
with a null value.

For ImportMixedTypes=Text, the data type for the whole column will be:

Jet (MS Access UI): 'Text' data type
DDL: VARCHAR(255)
ADO: adWChar ('a null-terminated Unicode character string')

Note that this is distinct from:

Jet (MS Access UI): 'Memo' data type
DDL: N/A
ADO: adLongVarWChar ('a long null-terminated Unicode string value')

ImportMixedTypes=Text will curtail text at 255 characters as 'Memo' is
cast as 'Text'. For a column to be recognized as 'Memo', majority type
must be detected, meaning the majority of rows detected must contain
255 or more characters.

But how many rows are scanned for each column before is decided that
mixed types exist? There is a second registry Key, TypeGuessRows. This
can be a value from 0-16 (decimal). A value from 1 to 16 inclusive is
the number of rows to scan. A value of zero means all rows will be
scanned.

In summary, use TypeGuessRows to get Jet to detect whether a 'mixed
types' situation exists or use it to 'trick' Jet into detecting a
certaint data type as being the majority type. In the event of a
'mixed types' situation being detected, use ImportMixedTypes to tell
Jet to either use the majority type or coerce all values as 'Text'
(max 255 characters).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top