Return Left Portion of a String

B

Bonnie

Returning the left portion of a string in a query.

i.e. if the string is: "[email protected]"

What combination of functions would return only "anybody"
or any number of characters on the left side of the string
before the @ character?
 
R

Rick Brandt

Bonnie said:
Returning the left portion of a string in a query.

i.e. if the string is: "[email protected]"

What combination of functions would return only "anybody"
or any number of characters on the left side of the string
before the @ character?

Left([YourField], InStr(1, [YourField], "@") - 1)
 
N

Newbie

Try something like . . . not tested

Sub GETSTRING()
TempStr = ""

MyString = Trim(Forms!form1!txtBox1.Value)

For i = 1 To (Len(MyString))
If Mid(MyString, i, 1) = "@" Then
TempStr = TempStr & Mid(MyString, i, 1)

End If
Next
End sub


HTH
 
N

Newbie

Ignore the last post!

Try this instead

Sub GETSTRING2()

MyString = "[email protected]"

TempStr = Left$(MyString, (InStr(1, MyString, "@", 0) - 1))
Debug.Print TempStr
End Sub

HTH
 
Top