Hello,
I am trying to extract part of a string field on a table. It has a
last name and it ends with a comma like "Smith,". I want to extract
the last name and dump the comma. I have this function, but it is not
working properly and it does not extract the comma from the string.
Anyone have any idea of what is going on?
Public Function GetString(InString As String) As String
GetString = IIf(InStr(InString, ",") > 0, Left(InString,
InStr(InString, ",")), InString)
End Function
Any help is appreciated! Thanks
Alan - 23 Nov 2004 17:45 GMT
> Hello,
>
[quoted text clipped - 10 lines]
>
> Any help is appreciated! Thanks
Considering you don't mention what language or db platform is involved, it's
going to be tough for anyone to give you any real help. But, the general
idea is to determine the position number of the comma, and use that as the
upper limit on a substring function. Something like:
GetString = SUBSTR(your_string_field,1,POS(your_string_field,','))
Syntax explained:
substr(field or 'string', start position, end position) and
pos(field or 'string','character(s) you are looking for')