update query

G

Guest

I have a table with records for example S-001,S-002,S-003 and i want to
update them to add an extra 0 in the front. I would like it to show
S-0001,S-0002,S-0003. Is there any way to do and update query to add the 0?
Thanks.
 
T

Tom Lake

Erik said:
I have a table with records for example S-001,S-002,S-003 and i want to
update them to add an extra 0 in the front. I would like it to show
S-0001,S-0002,S-0003. Is there any way to do and update query to add the 0?
Thanks.

Create an Update Query and under the field to be updated (I'll call it MyField) use
this
in the Replace With row:

Left([MyField], 2) & "0" & Mid([MyField], 3)

where Myfield is the name of your field.

Tom Lake
 
R

Rick Brandt

Erik said:
I have a table with records for example S-001,S-002,S-003 and i want
to update them to add an extra 0 in the front. I would like it to show
S-0001,S-0002,S-0003. Is there any way to do and update query to add
the 0? Thanks.

UPDATE TableName
SET [TableName]![FieldName] = Left([TableName]![FieldName], 2) & "0" &
Mid([TableName]![FieldName], 3)

The BETTER way to have set this table up is to store only the number in a
Long Integer field and then *display* it on forms and reports with the
expression...

=Format([FieldName], "S-000")

Then to make the change you simply change that expression to...

=Format([FieldName], "S-0000")
 

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

Similar Threads

Inserting a character 5
subquery 2
query to change the layout of a table 1
Record output in queries 1
help date and sum 3
Listing out Budget, Actual and Forecast 4
Update Query 1
CrossTab Query count with grouping 3

Top