Left Function


J

Joe Harman

Yes. The code to get the first name from a pair of names
separated by "&" would look something like this. For
simplicity, the code below uses a variable (str2Srch)
instead of a field name.

Function findstr()

Dim str2Srch As String
Dim strResult As String
Dim intLoc As Integer

' Set up the variable we're going to search
str2Srch = "Joe & Jim"

' Where is the Ampersand located?
intLoc = InStr(1, str2Srch, "&")

' Trim the string to get only the part before
' the ampersand and the space preceeding it and
' put it in strResult.
strResult = Left(str2Srch, intLoc - 2)

' strResult will now contain "Joe"

End Function
 
Ad

Advertisements


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