I was using the following InStr() to extract data from a field. The string I
am extracting begins with “!TCANC” and ends with an ASCII Null.
I have now recognized that there is a variant that begins with “!OCANC”.
How would I modify my InStr to allow for the variant?
Mid([TEXT],(InStr([TEXT],"!TCANC")),(InStr([TEXT],Chr(0))-InStr([TEXT],"!TCANC"))
IIF(Instr(1,[TEXT],"!TCANC")> 0,
Mid([TEXT],(InStr([TEXT],"!TCANC")),(InStr([TEXT],Chr(0))-InStr([TEXT],"!TCANC")),
Mid([TEXT],(InStr([TEXT],"!OCANC")),(InStr([TEXT],Chr(0))-InStr([TEXT],"!OCANC")))
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
> I was using the following InStr() to extract data from a field. The string I
> am extracting begins with “!TCANC” and ends with an ASCII Null.
[quoted text clipped - 4 lines]
>
> Mid([TEXT],(InStr([TEXT],"!TCANC")),(InStr([TEXT],Chr(0))-InStr([TEXT],"!TCANC"))
yator - 09 May 2008 17:04 GMT
John what does the "1" in the first InStr refer to? i.e.; IIF(Instr(1,
thanx
> IIF(Instr(1,[TEXT],"!TCANC")> 0,
> Mid([TEXT],(InStr([TEXT],"!TCANC")),(InStr([TEXT],Chr(0))-InStr([TEXT],"!TCANC")),
[quoted text clipped - 13 lines]
> >
> > Mid([TEXT],(InStr([TEXT],"!TCANC")),(InStr([TEXT],Chr(0))-InStr([TEXT],"!TCANC"))
John Spencer - 09 May 2008 18:19 GMT
InStr has an optional argument as the first argument. It is the Starting
position of the search for a match. I usually include it, but it is not
needed. Look it up in the VBA help.
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
> John what does the "1" in the first InStr refer to? i.e.; IIF(Instr(1,
> thanx
[quoted text clipped - 7 lines]
>> Center for Health Program Development and Management
>> University of Maryland Baltimore County
Try this --
My_String: IIF(Mid([TEXT],(InStr([TEXT],"!TCANC")),(InStr([TEXT],Chr(0)) Is
Null,
Mid([TEXT],(InStr([TEXT],"!OCANC")),(InStr([TEXT],Chr(0)),Mid([TEXT],(InStr([TEXT],"!TCANC")),(InStr([TEXT],Chr(0)))

Signature
KARL DEWEY
Build a little - Test a little
> I was using the following InStr() to extract data from a field. The string I
> am extracting begins with “!TCANC” and ends with an ASCII Null.
[quoted text clipped - 4 lines]
>
> Mid([TEXT],(InStr([TEXT],"!TCANC")),(InStr([TEXT],Chr(0))-InStr([TEXT],"!TCANC"))