Replace first Digit

  • Thread starter Thread starter mattc66 via AccessMonster.com
  • Start date Start date
M

mattc66 via AccessMonster.com

Hi All,

I want to replace the first digit in a text fld from a 1 to 8. What is the
best way to do this in a query. The length of digits very from 6 to 9.

Thanks
Matt
 
Hi All,

I want to replace the first digit in a text fld from a 1 to 8. What is the
best way to do this in a query. The length of digits very from 6 to 9.

Thanks
Matt

An UPDATE query should work:

UPDATE yourtable
SET yourfield = "8" & Mid([yourfield], 2)
WHERE yourfield LIKE "1*";

Back up your database first of course! Updates are irrevokable.

What this will do is select all records where the field yourfield
(you'll change this to your actual field name of course) begins with
the character 1, and update it to the concatenation of the character 8
with the second through last bytes of yourfield.

John W. Vinson[MVP]
 
If the field is a text and you want to do it permanently, use an update
query.

UPDATE YourTable
SET YourField = "8" & Mid([YourField],2)
WHERE YourField Like "1*"
 

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

Back
Top