Stripping a field value

  • Thread starter Thread starter JohnB
  • Start date Start date
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
 
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 "").
 
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.
 
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 "").
 
Hi again Marsh.

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