Replace first Digit

  • Thread starter mattc66 via AccessMonster.com
  • 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
 
J

John Vinson

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]
 
J

John Spencer

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*"
 
Top