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!
 
A

Allen Browne

Type an expression like this into the Field row in query design:
IIf([F1] Like "?*/*", Left([F1], Instr([F1], "/") - 1), [F1])

Substitute your field name for F1.
 
S

Stefan Hoffmann

hi William,
I need my query to strip off everything after & including the "/" so
that I get the following results.
Do I accomplish this using the INSTR function and if so how would it
work?
Create a standard modul:

Public Function StripAfter(AValue As Variant, _
Optional ADelimiter As String = "/" _
) As Variant

Dim Result As Variant

Result = AValue

If Not IsNull(Result) Then
Result = Left(Result, Instr(Result, "/") - 1)
End If

StripAfter = Result

End Function

You can call it in your query:

Stripped: StripAfter([fieldToStrip])


mfG
--> stefan <--
 

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