left()

message from =?Utf-8?B?Sk1vcnJlbGw=?= on 12 May 2004
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
 
Dirk Goldgar replied to =?Utf-8?B?Sk1vcnJlbGw=?= on 12 May 2004
"JMorrell" <anonymous@discussions.microsoft.com> wrote in message
news:482088F1-DFF8-4E0C-B9F8-F02FCACE6BB0@microsoft.com

One way:

Left(YourString, InStr(YourString, ",") - 1)
 
=?Utf-8?B?Sk1vcnJlbGw=?= replied to Dirk Goldgar on 13 May 2004
Right(Trim([selcat]), Len(Trim([selcat])) - InStr(1, [selcat], " "))

tiaa
 
Graham R Seach replied to =?Utf-8?B?Sk1vcnJlbGw=?= on 14 May 2004
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" <anonymous@discussions.microsoft.com> wrote in message
news:B31C4D17-1A42-45D3-BC1F-3599ECE371F7@microsoft.com...
(slightly)different direction with:
 

Archived message: left() (MS Access Error Message)