Connecting Tech Pros Worldwide Forums | Help | Site Map

program to rename image paths

campbellbrian2001@yahoo.com
Guest
 
Posts: n/a
#1: Nov 13 '05
This is probably quite simple to the VB veterans... here goes, I have a
database of product images with the name and server address hardcoded
into the field value (e.g. \\PC9\imageFiles\8965341.jpg) whereas
\\PC9\imageFiles was the old location of the .jpg 8965341). We have
switched the server names and now all the images need to be renamed
\\F:\imageFiles. Obviously if I had not misstakingly hardcoded the path
I could solve the problem in 2 minutes of coding.... but does anyone
know how to write a query that takes out the \\PC9\part of the name on
each record and replaces it with the \\F:\ path? Later I will delete
the path from the field altogether.
Thanks all for any help!
Brian


Douglas J. Steele
Guest
 
Posts: n/a
#2: Nov 13 '05

re: program to rename image paths


There's a Replace function you can use

UPDATE MyTable
SET MyField = Replace(MyField, " \\PC9\ ", " \\F:\ ")

(Note that I had to put extra spaces because Outlook Express insisted on
erasing them when it converted to a hyperlink!)

However, your mention of "VB veterans" has me wondering. Are you going to be
running this from within Access, or from outside of Access? The above will
only work if run inside of Access.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



<campbellbrian2001@yahoo.com> wrote in message
news:1119560944.921222.132210@g14g2000cwa.googlegr oups.com...[color=blue]
> This is probably quite simple to the VB veterans... here goes, I have a
> database of product images with the name and server address hardcoded
> into the field value (e.g. \\PC9\imageFiles\8965341.jpg) whereas
> \\PC9\imageFiles was the old location of the .jpg 8965341). We have
> switched the server names and now all the images need to be renamed
> \\F:\imageFiles. Obviously if I had not misstakingly hardcoded the path
> I could solve the problem in 2 minutes of coding.... but does anyone
> know how to write a query that takes out the \\PC9\part of the name on
> each record and replaces it with the \\F:\ path? Later I will delete
> the path from the field altogether.
> Thanks all for any help!
> Brian
>[/color]


campbellbrian2001@yahoo.com
Guest
 
Posts: n/a
#3: Nov 13 '05

re: program to rename image paths


Thanks Douglas! but a couple of problems. I made this just a query
under query design with the following line of SQL:

UPDATE [VFProducts].Picture SET VFProducts.Picture =
Replace(VFProducts.Picture, "\\PC9\Common\","F:\");

But I get an error message saying "Couldn't find
"C:\MyDocuments\VFaccess.mdb"
Any clues? I tried to put the SQL as an event procedure on a form with
a button control and this didn't work either.
Thanks all!
Brian


Douglas J. Steele wrote:[color=blue]
> There's a Replace function you can use
> UPDATE MyTable
> SET MyField = Replace(MyField, " \\PC9\ ", " \\F:\ ")
> (Note that I had to put extra spaces because Outlook Express insisted on
> erasing them when it converted to a hyperlink!)
> However, your mention of "VB veterans" has me wondering. Are you going to be
> running this from within Access, or from outside of Access? The above will
> only work if run inside of Access.
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)[/color]
[color=blue]
> <campbellbrian2001@yahoo.com> wrote in message[color=green]
> > This is probably quite simple to the VB veterans... here goes, I have a
> > database of product images with the name and server address hardcoded
> > into the field value (e.g. \\PC9\imageFiles\8965341.jpg) whereas
> > \\PC9\imageFiles was the old location of the .jpg 8965341). We have
> > switched the server names and now all the images need to be renamed
> > \\F:\imageFiles. Obviously if I had not misstakingly hardcoded the path
> > I could solve the problem in 2 minutes of coding.... but does anyone
> > know how to write a query that takes out the \\PC9\part of the name on
> > each record and replaces it with the \\F:\ path? Later I will delete
> > the path from the field altogether.
> > Thanks all for any help!
> > Brian[/color][/color]

Douglas J. Steele
Guest
 
Posts: n/a
#4: Nov 13 '05

re: program to rename image paths


Don't know whether this is what's causing your error, but your UPDATE
statement syntax is incorrect. It should be

UPDATE [VFProducts] SET VFProducts.Picture =
Replace(VFProducts.Picture, "\\PC9\Common\","F:\");


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



<campbellbrian2001@yahoo.com> wrote in message
news:1120137264.296526.53990@f14g2000cwb.googlegro ups.com...[color=blue]
> Thanks Douglas! but a couple of problems. I made this just a query
> under query design with the following line of SQL:
>
> UPDATE [VFProducts].Picture SET VFProducts.Picture =
> Replace(VFProducts.Picture, "\\PC9\Common\","F:\");
>
> But I get an error message saying "Couldn't find
> "C:\MyDocuments\VFaccess.mdb"
> Any clues? I tried to put the SQL as an event procedure on a form with
> a button control and this didn't work either.
> Thanks all!
> Brian
>
>
> Douglas J. Steele wrote:[color=green]
>> There's a Replace function you can use
>> UPDATE MyTable
>> SET MyField = Replace(MyField, " \\PC9\ ", " \\F:\ ")
>> (Note that I had to put extra spaces because Outlook Express insisted on
>> erasing them when it converted to a hyperlink!)
>> However, your mention of "VB veterans" has me wondering. Are you going to
>> be
>> running this from within Access, or from outside of Access? The above
>> will
>> only work if run inside of Access.
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)[/color]
>[color=green]
>> <campbellbrian2001@yahoo.com> wrote in message[color=darkred]
>> > This is probably quite simple to the VB veterans... here goes, I have a
>> > database of product images with the name and server address hardcoded
>> > into the field value (e.g. \\PC9\imageFiles\8965341.jpg) whereas
>> > \\PC9\imageFiles was the old location of the .jpg 8965341). We have
>> > switched the server names and now all the images need to be renamed
>> > \\F:\imageFiles. Obviously if I had not misstakingly hardcoded the path
>> > I could solve the problem in 2 minutes of coding.... but does anyone
>> > know how to write a query that takes out the \\PC9\part of the name on
>> > each record and replaces it with the \\F:\ path? Later I will delete
>> > the path from the field altogether.
>> > Thanks all for any help!
>> > Brian[/color][/color]
>[/color]


Closed Thread


Similar Microsoft Access / VBA bytes