convert field data type from text to number

ajm

Well-known Member
Joined
Feb 5, 2003
Messages
2,007
Office Version
  1. 365
Platform
  1. Windows
how does one convert a field from text to numbers in access? in my table, one field for customer numbers is stored as text. it contains proper numbers and also "text" numbers where the number starts with an alpha character. I have tried to change the format of the field in the table set up. I have tried to multiply the customer numbers by 1 to create real numbers.

but i keep losing data. I am currently trying to write an "iif" function to the effect that if the customer number starts with an alpha, leave it as is, else multiply by one.

Can anyone please help with a solution?

ajm
 
A low tech solution is to use an import template that contains dummy data (Text, integer, decimal, or date, as needed, in the first row, or even the first 10-50 rows to be safe. Usually its when you have a number in the first row and text later on in the same column that you get stung - as often happens with ID's that can have numeric values or text values). Then run a delete query to delete the dummy row, or import to a staging table and append to the real table without the dummy row.

text, 1, 1.31, 12/31/2011
 
Last edited:
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
due to excel's guess work when selecting data type, i had put several alpha numeric customer ids at the start of the table to try and force access to make that field a text field. but no luck. unless its of major interest to anyone, i managed a workaround which will do for now so am quite happy for this query to go to the keeper. many thanks Phil, Norie, Joe, Xenou
 
Upvote 0
Did you try creating a blank table with fields of the correct data type(s)?

With that you wouldn't need to do anything with the data in Excel.
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,743
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top