J
Jim Jones
I have a table in which student names are captured as surname followed by
first names. I then rotate the names so that Jones Jim becomes Jim Jones. I
do so by using the following code:
Function Invert_Name(nam)
sep = InStr(1, nam, " ")
If sep = 0 Then
Invert_Name = nam
Exit Function
End If
fnam= Right(nam, Len(nam) - sep)
lnam = Left(nam, sep - 1)
Invert_Name = fname & " " & lnam
End Function
This works fine and Jones Jim becomes Jim Jones. However, the it does not
work when there are more than one first name - so Jones Jim Edward does not
rotate. How can I amend the code so that the rotation takes place when the
first space is reached, whilst any other subsequent spaces just become part
of the fist name string?
Any help would be much appreciated.
Jim Jones
Ministry of Education
Botswana
first names. I then rotate the names so that Jones Jim becomes Jim Jones. I
do so by using the following code:
Function Invert_Name(nam)
sep = InStr(1, nam, " ")
If sep = 0 Then
Invert_Name = nam
Exit Function
End If
fnam= Right(nam, Len(nam) - sep)
lnam = Left(nam, sep - 1)
Invert_Name = fname & " " & lnam
End Function
This works fine and Jones Jim becomes Jim Jones. However, the it does not
work when there are more than one first name - so Jones Jim Edward does not
rotate. How can I amend the code so that the rotation takes place when the
first space is reached, whilst any other subsequent spaces just become part
of the fist name string?
Any help would be much appreciated.
Jim Jones
Ministry of Education
Botswana