urjudo
asked on
How to pull last name only from two difference login
Hi Experts,
I have a question about how to pull only last name under two difference login.
a). Login as John.Doe
how do I only pull Doe
b). JDoe
how do I only pull Doe
Thanks,
I have a question about how to pull only last name under two difference login.
a). Login as John.Doe
how do I only pull Doe
b). JDoe
how do I only pull Doe
Thanks,
This function will return the characters after any specified character(s):
<><>
Function LastBit(strNa As String, optional strDelimiter As String)
'this function returns the characters to the right of the first sought character
'if no delimiter is passed in, a space will be used as the delimiter
If strDelimiter = "" Then strDelimiter = " "
'SEEKING FROM THE RIGHT END OF THE STRING
LastBit = Right(strNa, Len([strNa]) - InStrRev([strNa], strDelimiter))
End Function
<><>
so pasting ?LastBit("John.Doe", ".") in the immediate window will return
Doe
If you want to return only the first character of a string, use
<><>
Public Function FirstChar(strText As String) As String
FirstChar = Left(strText, 1)
End Function
<><>
pasting ?FirstChar("JDoe") into the immediate window will return
J
<><>
Function LastBit(strNa As String, optional strDelimiter As String)
'this function returns the characters to the right of the first sought character
'if no delimiter is passed in, a space will be used as the delimiter
If strDelimiter = "" Then strDelimiter = " "
'SEEKING FROM THE RIGHT END OF THE STRING
LastBit = Right(strNa, Len([strNa]) - InStrRev([strNa], strDelimiter))
End Function
<><>
so pasting ?LastBit("John.Doe", ".") in the immediate window will return
Doe
If you want to return only the first character of a string, use
<><>
Public Function FirstChar(strText As String) As String
FirstChar = Left(strText, 1)
End Function
<><>
pasting ?FirstChar("JDoe") into the immediate window will return
J
ASKER
answer for Rey Obrero.
a). yes, first name and Last name is separated by a dot
b). sorry, they are lowercase. (jdoe)
a). yes, first name and Last name is separated by a dot
b). sorry, they are lowercase. (jdoe)
a. mid("John.Doe", Instr("John.Doe",".")+1)
b. mid("jdoe",2)
b. mid("jdoe",2)
ASKER
sorry, Rey Obrero. I forgot to let you know that is a field name username.
if instr(login,".") then
Lname=mid(login, Instr(login,".")+1)
else
LName=mid(login,2)
end if
Lname=mid(login, Instr(login,".")+1)
else
LName=mid(login,2)
end if
Ooop-- misread your second question. Sorry! Rey is correct.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
is anyway I can put into a query?
ASKER
got it
ASKER
Thank you!!!
a. separated by a dot
b. first and second letter are uppercase
confirm if this is correct.
this can be done using VBA codes