Last word first in table

  • Thread starter Thread starter deb
  • Start date Start date
D

deb

I have a table called Products with a field called Description.
How can I take the data in the field "Description" and have the last word
moved to the first word.

example
Blue ink pen 124-JOH
Thin Paper 128763

changed to

124-JOH Blue ink pen
128763 Thin Paper

Thanks
 
UPDATE Products
SET Description = Mid([Description], InStrRev([Description], " ") + 1) & "
" & Left([Description], InStrRev([Description], " ") - 1)
WHERE InStrRev([Description], " ") > 0

I'd strongly recommending doing this on a copy of the table the first time,
to make sure it's what you want!
 
thank you for your quick response.

When I used this, it replaced everything and only kept the last work.
I need the last work moved to be the first word in the field while keeping
everything else too.

any suggestions?

Thanks again
--
deb


Douglas J. Steele said:
UPDATE Products
SET Description = Mid([Description], InStrRev([Description], " ") + 1) & "
" & Left([Description], InStrRev([Description], " ") - 1)
WHERE InStrRev([Description], " ") > 0

I'd strongly recommending doing this on a copy of the table the first time,
to make sure it's what you want!

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


deb said:
I have a table called Products with a field called Description.
How can I take the data in the field "Description" and have the last word
moved to the first word.

example
Blue ink pen 124-JOH
Thin Paper 128763

changed to

124-JOH Blue ink pen
128763 Thin Paper

Thanks
 
How did you use it? That's the SQL for an Update query. Running the update
query should change every entry in the table in one fell swoop.

And just in case the word-wrap cause confusion, it's

UPDATE Products
SET Description =
Mid([Description], InStrRev([Description], " ") + 1) &
" " & Left([Description], InStrRev([Description], " ") - 1)
WHERE InStrRev([Description], " ") > 0


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


deb said:
thank you for your quick response.

When I used this, it replaced everything and only kept the last work.
I need the last work moved to be the first word in the field while keeping
everything else too.

any suggestions?

Thanks again
--
deb


Douglas J. Steele said:
UPDATE Products
SET Description = Mid([Description], InStrRev([Description], " ") + 1) &
"
" & Left([Description], InStrRev([Description], " ") - 1)
WHERE InStrRev([Description], " ") > 0

I'd strongly recommending doing this on a copy of the table the first
time,
to make sure it's what you want!

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


deb said:
I have a table called Products with a field called Description.
How can I take the data in the field "Description" and have the last
word
moved to the first word.

example
Blue ink pen 124-JOH
Thin Paper 128763

changed to

124-JOH Blue ink pen
128763 Thin Paper

Thanks
 
Back
Top