Extract first part of text string

K

Kimbur

How can I extract the first part of a text string when it is varying lengths?
I need to pull the first few characters of the string (between 1 and 5
characters) that are always before the first space (" "). I have strings
which look like this, "1 APOL 70-145-01" and "2-1/2 APOL 70-109-01A" so my
desired result would be "1" and "2-1/2" respectively.
 
S

Stefan Hoffmann

hi,
How can I extract the first part of a text string when it is varying lengths?
I need to pull the first few characters of the string (between 1 and 5
characters) that are always before the first space (" "). I have strings
which look like this, "1 APOL 70-145-01" and "2-1/2 APOL 70-109-01A" so my
desired result would be "1" and "2-1/2" respectively.
Use

Left$(yourString, InStr$(yourString, " ") - 1)

in either code, a query or as a control source.


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