Delete Specific Characters From Text

J

Jeff Monroe

I am trying to create an Update Query that will strip out certai
characters from a string in a text field (specifically hyphens an
slashes) while leaving the rest of the data in the record alone. Th
characters do not exist in all records and they are located i
different positions in the field.

Examples: 1234-01, 12345-01, ABC/D, WX-YZ.
Desired Result: 123401, 1234501, ABCD, WXYZ.

Thanks for any help.
jef
 
M

MGFoster

Jeff said:
I am trying to create an Update Query that will strip out certain
characters from a string in a text field (specifically hyphens and
slashes) while leaving the rest of the data in the record alone. The
characters do not exist in all records and they are located in
different positions in the field.

Examples: 1234-01, 12345-01, ABC/D, WX-YZ.
Desired Result: 123401, 1234501, ABCD, WXYZ.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Try this:

UPDATE table_name
SET column_name = Replace(Replace(column_name, "-",""),"/","")
WHERE column_name LIKE "*[/-]*"

Substitute your table name and column name where appropriate.

See the VBA Help article on the Replace Function for more info.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSZJAhoechKqOuFEgEQIuwACePAZLkVWrqkt6HRyxXxkGZRmcZH0Aniqx
l8z6JcnMeWDRJLavj3dO6LyI
=izvD
-----END PGP SIGNATURE-----
 
J

Jeff Monroe

MG:

Thank you very much for the tip. It worked exaclty as I needed. You
saved me hours of manually deleting the characters I don't want.

Jeff
 

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