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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error on reading number not string from Excel

Status
Not open for further replies.

martinm

IS-IT--Management
Mar 30, 2001
113
0
0
GB
My App happily reads strings from a spreadsheet. These values may now be numbers (i.e. have no aplha chars in them).

The individual cells have to be formatted as text, otherwise I get a runtime error 'Numeric field overflow' on accessing this value. I thought that the data was retrieved as a variant, so shouldn't make any different what type it is?

Even

Nz(rsImport(1), "")

Causes the error!

I'm connecting thus, and retrieving with 'select * from'

Set ltb = db.CreateTableDef(strLink_name)
ltb.Connect = xConnection_string
ltb.SourceTableName = xTable



Any one explain this?

Ta.
 



Hi,

In Excel, changing the formatting changes ABSOLUTELY NOTHING, except what you see. The underlying value remains UNCHANGED!

So, if you have a column that contains BOTH alpha-numeric (TEXT) and numeric (NUMBERS), after you format the column as TEXT, you STILL have BOTH alpha-numeric (TEXT) and numeric (NUMBERS). This condition alone, will cause problems when you attempt to query.

The solution is to fix the data in Excel by prepending an APOSTROPHY (Excel's identifier for a LABEL or TEXT) which will convert the number to a string.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thanks, trouble is I can't see why there is a problem, as everything is returned as a variant, so is not typed?
 



Not so! The Query Manager, analyzes the data in the columm and ASSUMES a type, usually based on the first 8 rows.

If it assumes TEXT, your numeric values will be 'majorly honked' to put it is 'teknikl' terms. ;-)

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Ah, interesting. So they're variants, but of a single type. Bl**dy Microsoft.

Thanks, I'll let the user know they need to use the ' .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top