Access Query - INSTR function?

W

William

I'm using a query and need strip out data.
Here is an example of the data I have to work with:

85123147/RS08
85123147W/RS08
TEX-M/SS09

I need my query to strip off everything after & including the "/" so
that I get the following results.

85123147
85123147W
TEX-M

Do I accomplish this using the INSTR function and if so how would it
work?

I would appreciate some guidance.
Thank you!

William.
 
J

John Spencer

As I recall you can't use the VBA constants in a query. You will need
to replace vbTextCompare with 1 in the expression.

Also, the expression ASSUMES that there will ALWAYS be a "/" in your
field. If that is not the case you can append a slash mark to the very
end of the field you are testing and take care of the problem.

So, all in all you might use:

Left([YourFieldName],InStr(1, [YourFieldName] & "/", "/", 1)-1)


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

Left([YourFieldName],InStr(1, [YourFieldName], "/", vbTextCompare)-1)

William said:
I'm using a query and need strip out data.
Here is an example of the data I have to work with:

85123147/RS08
85123147W/RS08
TEX-M/SS09

I need my query to strip off everything after & including the "/" so
that I get the following results.

85123147
85123147W
TEX-M

Do I accomplish this using the INSTR function and if so how would it
work?

I would appreciate some guidance.
Thank you!

William.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top