Part of a text field

A

Ant S

I have a field containing a file name e.g. My Pictuer_25.jpg where "My
Pictuer" is the title of an image, and "25" is a membership number. I would
like to automatically populate a strTitel field with just the title part of
the file name e.g all left most letters up to but not including the
underscore. I am thinking along the lines of =Left(FileName,???) but don't
know how to "express up to _"

Thanks for any help
 
S

Stuart McCall

Ant S said:
I have a field containing a file name e.g. My Pictuer_25.jpg where "My
Pictuer" is the title of an image, and "25" is a membership number. I
would like to automatically populate a strTitel field with just the title
part of the file name e.g all left most letters up to but not including the
underscore. I am thinking along the lines of =Left(FileName,???) but don't
know how to "express up to _"

Thanks for any help

=Left(FileName, Instr(1, FileName, "_") - 1)

The Instr function returns the point in the string where the underscore is.
Then 1 is subtracted from that and the result passed to the Left function.
 
A

Ant S

Thanks Stuart, that worked as did your help with loading file names last
week! almost done now and ready to deploy!
 
S

Stuart McCall

Ant S said:
Thanks Stuart, that worked as did your help with loading file names last
week! almost done now and ready to deploy!

Good luck. Hope the client is happy.
 

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