Stripping a field value

J

JohnB

Hi. Can anyone help with this please?

I have a field called Image which contains the path and Image name e.g.

C:\My Documents\My Pictures\Mvc0000.jpg

If I have this field called up in a query, is there an expression I can put
in an empty field in the query so that it just contains the Image name e.g.
Mvc0000.jpg

It's likely that the path will always contain the same number of folders but
ideally the code should be able to cope with different path lengths.

Thanks for any help. JohnB
 
J

John Spencer (MVP)

Take a look at the DIR function.

DIR (SomePath) returns a string with the matching file.

Dir("C:\My Documents\My Pictures\Mvc0000.jpg") returns Mvc0000.jpg if
Mvc0000.jpg exists, otherwise it will return a zero length string (that is "").
 
M

Marshall Barton

JohnB said:
I have a field called Image which contains the path and Image name e.g.

C:\My Documents\My Pictures\Mvc0000.jpg

If I have this field called up in a query, is there an expression I can put
in an empty field in the query so that it just contains the Image name e.g.
Mvc0000.jpg

It's likely that the path will always contain the same number of folders but
ideally the code should be able to cope with different path lengths.


Dir(Image) will return Mvc0000.jpg as long as the path and
file actually exist and a zero length string if not.
 
J

JohnB

Thanks John. That works great. JohnB
John Spencer (MVP) said:
Take a look at the DIR function.

DIR (SomePath) returns a string with the matching file.

Dir("C:\My Documents\My Pictures\Mvc0000.jpg") returns Mvc0000.jpg if
Mvc0000.jpg exists, otherwise it will return a zero length string (that is "").
 
J

JohnB

Hi again Marsh.

Thank you also for your reply. Just tried it and it works a treat. Regards,
JohnB
 

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

Top