find last occurance of a character in a string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a formula or expression that will tell me the index of last occurance
of a character in a string.
 
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".
 
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.
 
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.
 
Back
Top