left()

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've seen it here before but can't find it now. How do I take a string and find all the characters to the left of a comma

e.g., 3459,fred would return just the 345

tia
 
JMorrell said:
I've seen it here before but can't find it now. How do I take a
string and find all the characters to the left of a comma?

e.g., 3459,fred would return just the 3459

tia

One way:

Left(YourString, InStr(YourString, ",") - 1)
 
That help a lot. Thanks. I took it a step further in a (slightly)different direction with

Right(Trim([selcat]), Len(Trim([selcat])) - InStr(1, [selcat], " ")

tiaa
 
JMorrell,

Did I miss something here?? I thought you wanted the chars to the left of
the comma??

Your result returns nothing like Dirk's suggestion, unless the quoted space
at the end is actually meant to be a comma. Even then, Dirks code is far
more efficient.

Using Dirk's general approach, the following would be better:
Mid([selcat], Instr(1, [selcat], ",") + 1)
or
Right([selcat], Instr(1, [selcat], ",") - 1)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


JMorrell said:
That help a lot. Thanks. I took it a step further in a
(slightly)different direction with:
Right(Trim([selcat]), Len(Trim([selcat])) - InStr(1, [selcat], " "))

tiaa
 
Back
Top