find last occurance of a character in a string

G

Guest

I need a formula or expression that will tell me the index of last occurance
of a character in a string.
 
J

Jeff Boyce

If I remember correctly, there's a function that reverses a string of
characters (I think I saw it at mvps.org/access, but you may wish to Google
for it, too).

Use that function to turn the string around and find the first occurrence,
then use the Len() function to determine the length of the string. Length
minus first location (in reversed string) would give you "last occurrence".
 
P

PC Datasheet

You need to loop through the string right to left one character at a time
checking each character to see if it is the character you are looking for.
The loop starts at Len([MyString]) and iterates by Step -1.
 
J

John Spencer (MVP)

If you are using a version of Access that is greater than Access 2000, you
should be able to use the VBA function InStrRev. I don't have the help
available on this computer, so I can't help you with the syntax.
 

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