Return Left Portion of a String

  • Thread starter Thread starter Bonnie
  • Start date Start date
B

Bonnie

Returning the left portion of a string in a query.

i.e. if the string is: "(e-mail address removed)"

What combination of functions would return only "anybody"
or any number of characters on the left side of the string
before the @ character?
 
Bonnie said:
Returning the left portion of a string in a query.

i.e. if the string is: "(e-mail address removed)"

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)
 
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
 
Ignore the last post!

Try this instead

Sub GETSTRING2()

MyString = "(e-mail address removed)"

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

HTH
 
Back
Top