View Full Version : Convert Text Column to Number


jiblankman
01-08-2009, 06:20 AM
I have a datatable with a column of numeric data. The column was originally assigned a type "number" but was converted to "text" by a user.

I need to change back to "number" but I get an error message that says: Microsoft Access encountered errors while converting the data. The contents of field in 443 record(s) were deleted. Do you want to proceed anyway?

I tried adding a new field and running an update query which assigns the value of the original column to the new column using the CInt, Cdbl and Val functions. I get the same result. Some of the values (443 exactly) are not convereted. As these were originally numbers, I do not understand what is happening.

Unfortunately, this is messing up a number of reports and queries which I need to be able to run. Can anyone help me correct this issue? Thanks.

boblarson
01-08-2009, 06:31 AM
Those 443 values probably include spaces and you can't add spaces to a number column.

midmented
01-08-2009, 06:38 AM
If there are spaces involved, I think I'd use something like Cint(Trim([FieldName]).

Just something off the top of my head.
Maybe someone used and O's instead of a zeros?

jiblankman
01-08-2009, 07:16 AM
As far as I can tell, none of the data has any spaces or O's (letter).

I tried exporting the table to and excel document and creating a new column of numbers, but cannot designate these as numbers when importing the table back into access.

MSAccessRookie
01-08-2009, 07:27 AM
I have a datatable with a column of numeric data. The column was originally assigned a type "number" but was converted to "text" by a user.

I need to change back to "number" but I get an error message that says:

I tried adding a new field and running an update query which assigns the value of the original column to the new column using the CInt, Cdbl and Val functions. I get the same result. Some of the values (443 exactly) are not convereted. As these were originally numbers, I do not understand what is happening.

Unfortunately, this is messing up a number of reports and queries which I need to be able to run. Can anyone help me correct this issue? Thanks.

I have a datatable with a column of numeric data. The column was originally assigned a type "number" but was converted to "text" by a user.

I need to change back to "number" but I get an error message that says:

I tried adding a new field and running an update query which assigns the value of the original column to the new column using the CInt, Cdbl and Val functions. I get the same result. Some of the values (443 exactly) are not convereted. As these were originally numbers, I do not understand what is happening.

Unfortunately, this is messing up a number of reports and queries which I need to be able to run. Can anyone help me correct this issue? Thanks.


Without seeing the data it is difficult to assist you here. Try the following steps, and report back with the results:
Make a COPY of your database.
In the DESIGN VIEW of the database copy, Add a new column (type Text) to use for making a copy of the column that has the problem.
Copy the values from the OLD COLUMN into the NEW COLUMN.
Convert the NEW COLUMN only.
Compare the OLD COLUMN to the NEW COLUMN. The error values should have a NULL In the NEW COLUMN

jiblankman
01-08-2009, 07:40 AM
The same result occurs. The fields that did not convert are left blank.

boblarson
01-08-2009, 08:26 AM
The same result occurs. The fields that did not convert are left blank.

I would say that the next thing to do is to post your database (or at least one with a copy of the table with the applicable fields in it).

jiblankman
01-08-2009, 08:52 AM
Here is a copy of the database table with all other information removed for privacy reasons.

Mike375
01-08-2009, 09:14 AM
When you change the field type to Number then go to the bottom of table design page and select Double instead of the Integer default.

jiblankman
01-08-2009, 09:56 AM
Thank you. I feel a little stupid that I didn't notice that.