String

K

Kim

I have a value 123-456-789. I want to be able to see everything to the left
of the last dash (123-456). The format of the value may change as well as
the number of dashes in the value. Anyone have any ideas?

Thanks,

Kim
 
B

Brendan Reynolds

? left$("123-456-789",instrrev("123-456-789","-")-1)
123-456

InStrRev returns the position of the last hyphen, and we take 1 from that
because we don't want to include the hyphen itself. See InStrRev Function
and Left Function in the help file for details.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
D

Dirk Goldgar

Kim said:
I have a value 123-456-789. I want to be able to see everything to
the left of the last dash (123-456). The format of the value may
change as well as the number of dashes in the value. Anyone have any
ideas?

Thanks,

Kim

Left([YourString], InStrRev([YourString], "-") - 1)
 
F

fredg

I have a value 123-456-789. I want to be able to see everything to the left
of the last dash (123-456). The format of the value may change as well as
the number of dashes in the value. Anyone have any ideas?

Thanks,

Kim

If you are using Access 2002 (or possibly Access 2000) or newer:
NewField = Left([FieldName],InStrRev([FieldName],"-")-1)
 
Top