You didn't indicate what error you got, so I'll assume it is has to do with
there being a NULL value in your field. Try:
SELECT Data.Ref,
IIF(ISNULL([Ref]), "N/A",
Mid([Ref],InStr([Ref],"/")+1,InStr([Ref],"/")-InStr([Ref],"/")-1)) AS B
FROM Data;
Actually, now that I take a closer look, I see that you dropped the
INSTRREV( ) function at the end. Keeping in mind that these text functions
won't work with a NULL value, It should be:
SELECT Data.Ref,
IIF(ISNULL([Ref]),
"N/A",
Mid([Ref],InStr([Ref],"/")+1,InStr([Ref],"/")-InStrRev([Ref],"/")-1)) AS B
FROM Data;
HTH
Dale
--
Email address is not valid.
Please reply to newsgroup only.
:
SELECT Data.Ref,
Mid([Ref],InStr([Ref],"/")+1,InStr([Ref],"/")-InStr([Ref],"/")-1) AS B
FROM Data;
:
Worked fine in the immediate window. Post your entire SQL string and I'll
see what I can do. It would also be nice to know what error your get.
Dale
--
Email address is not valid.
Please reply to newsgroup only.
:
I put in the following and I get an error.
B: Mid([Ref],InStr([Ref],"/")+1,InStr([Ref],"/")-InStr([Ref],"/")-1)
:
In a query, if you are certain that A is separated from B and B from C using
the "/", you could use:
B:Mid([yourField], instr([yourField], "/")+1, instrrev([yourField], "/") -
instr([yourField], "/") - 1)
HTH
Dale
Hello,
I have a field which has the following structure:
A/B/C
I need "B" but it can be any length (for the sake of argument). thanks