PDA

View Full Version : Return Left Portion of a String


Bonnie
June 1st, 2004, 01:46 PM
Returning the left portion of a string in a query.

i.e. if the string is: "

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

Rick Brandt
June 1st, 2004, 02:06 PM
"Bonnie" > wrote in message
...
> Returning the left portion of a string in a query.
>
> i.e. if the string is: "
>
> 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)


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Newbie
June 1st, 2004, 02:12 PM
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
"Bonnie" > wrote in message
...
> Returning the left portion of a string in a query.
>
> i.e. if the string is: "
>
> What combination of functions would return only "anybody"
> or any number of characters on the left side of the string
> before the @ character?
>

Newbie
June 1st, 2004, 02:23 PM
Ignore the last post!

Try this instead

Sub GETSTRING2()

MyString = "

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

HTH
"Newbie" > wrote in message
...
> 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
> "Bonnie" > wrote in message
> ...
> > Returning the left portion of a string in a query.
> >
> > i.e. if the string is: "
> >
> > What combination of functions would return only "anybody"
> > or any number of characters on the left side of the string
> > before the @ character?
> >
>
>

Google