Removing dashes from a number

C

CH

I'm trying to update a number field with numbers that have dashes in them.
For example: I'd like to change 620-46-3 to 620463. I know this can be done
with Find and Replace, but I have over 10,000 entries so I'm looking for
another way. Does anyone know what command to use in a query to be able to
take out the dashes for many different numbers? Thanks.
 
M

Marshall Barton

CH said:
I'm trying to update a number field with numbers that have dashes in them.
For example: I'd like to change 620-46-3 to 620463. I know this can be done
with Find and Replace, but I have over 10,000 entries so I'm looking for
another way. Does anyone know what command to use in a query to be able to
take out the dashes for many different numbers? Thanks.


Use an Update query, BUT first Make a backup copy of the
table in case something goes wrong.

UPDATE [the table]
SET [the field] = Replace([the field], "-", "")
 
F

fredg

I'm trying to update a number field with numbers that have dashes in them.
For example: I'd like to change 620-46-3 to 620463. I know this can be done
with Find and Replace, but I have over 10,000 entries so I'm looking for
another way. Does anyone know what command to use in a query to be able to
take out the dashes for many different numbers? Thanks.


1) If the field contains dashes then it cannot be a Number field. It's
Text.

2) Permanently remove the dashes?
You need an Update query.

Update YourTable Set YourTable.FieldName = Replace([FieldName],"-","")
 
J

John Spencer

You can use the REPLACE function in an update query if your version of
Access is later than Access 2000.

UPDATE YourTable
SET YourNumberField = Replace(YourNumberField,"-","")
WHERE YOurNumberField like "*-*"

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
J

John W. Vinson

I'm trying to update a number field with numbers that have dashes in them.
For example: I'd like to change 620-46-3 to 620463. I know this can be done
with Find and Replace, but I have over 10,000 entries so I'm looking for
another way. Does anyone know what command to use in a query to be able to
take out the dashes for many different numbers? Thanks.

Well, a Number field cannot have dashes in it! What's in your table now -
datatypes? Is this numbers in a Text field, or are you trying to migrate data
from a text field containing numbers into a Number field, or are the hyphens
perhaps coming from an Input Mask?
 

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