Need help in Syntax

M

Me

How do I extract portion of data from a field delimited by say '/'?

Example if I have - 'abcdef/ijk/efdfdfd' or 'xyz/dfdfd'

I would like to get 'abcdef' in 1st case and 'xyz' in the 2nd case.

Thank you in advance,
-Me
 
M

MGFoster

Me said:
How do I extract portion of data from a field delimited by say '/'?

Example if I have - 'abcdef/ijk/efdfdfd' or 'xyz/dfdfd'

I would like to get 'abcdef' in 1st case and 'xyz' in the 2nd case.

Thank you in advance,
-Me

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use the Left$() and Instr() functions:

Left$("abcdef/ijk/efdfdfd", Instr("abcdef/ijk/efdfdfd", "/")-1)

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSezyo4echKqOuFEgEQJmhQCeOf+3WI+g/g5st3Mkuwwi9ditcg4AoJtr
VYA0/Ud9z1R5io0u9jFg3Ya2
=AUh2
-----END PGP SIGNATURE-----
 
M

Me

Karl,

This works, however I forgto to add that there are records without any "/"
in the data, how do I handle both together?

Like 'abcd/efg' and 'xyzabcedfe'

so I should be able to retrieve 'abcd' and 'xyzabcedfe'.

Appreciate your help!
-Me

KARL DEWEY said:
Left([YourField], Instr([YourField],"/")-1)


Me said:
How do I extract portion of data from a field delimited by say '/'?

Example if I have - 'abcdef/ijk/efdfdfd' or 'xyz/dfdfd'

I would like to get 'abcdef' in 1st case and 'xyz' in the 2nd case.

Thank you in advance,
-Me
 
K

KARL DEWEY

IIF(Instr([YourField],"/")<0, [YourField], Left([YourField],
Instr([YourField],"/")-1)


Me said:
Karl,

This works, however I forgto to add that there are records without any "/"
in the data, how do I handle both together?

Like 'abcd/efg' and 'xyzabcedfe'

so I should be able to retrieve 'abcd' and 'xyzabcedfe'.

Appreciate your help!
-Me

KARL DEWEY said:
Left([YourField], Instr([YourField],"/")-1)


Me said:
How do I extract portion of data from a field delimited by say '/'?

Example if I have - 'abcdef/ijk/efdfdfd' or 'xyz/dfdfd'

I would like to get 'abcdef' in 1st case and 'xyz' in the 2nd case.

Thank you in advance,
-Me
 
J

John Spencer

Easy way to to append a slash to the end of the field in the Instr function:

Left([YourField], Instr([YourField] & "/","/")-1)


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

Karl,

This works, however I forgto to add that there are records without any "/"
in the data, how do I handle both together?

Like 'abcd/efg' and 'xyzabcedfe'

so I should be able to retrieve 'abcd' and 'xyzabcedfe'.

Appreciate your help!
-Me

KARL DEWEY said:
Left([YourField], Instr([YourField],"/")-1)


Me said:
How do I extract portion of data from a field delimited by say '/'?

Example if I have - 'abcdef/ijk/efdfdfd' or 'xyz/dfdfd'

I would like to get 'abcdef' in 1st case and 'xyz' in the 2nd case.

Thank you in advance,
-Me
 

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