Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split Text Field When Spaces Vary

Status
Not open for further replies.

aj3221

Technical User
May 14, 2008
79
US
I have a field where the spacing in the middle could change.

Example 1: 332 31
Example 2: 332 9
Example 3: 041 12

I need to split this field into 2 parts. The space in the middle is what I was trying to split on but my example # 2 is returning a space then the 9. I need it to just return the 9. I also tried the left and the right formulas but in some cases it was grabbing just the 9 but then it would throw off the others (I would return the 1 in Example 1 and the 2 in Example 2).

I want my results to be:
Truck# Stop#
Example 1: 332 31
Example 2: 332 9
Example 3: 041 12

Any advice would be greatly appreciated. Thanks in advance!
 
Try using Instr() instead

@Field1
Right(Yourfield, Instr(yourField, " ")-1)
@Field2
Mid(Yourfield, Instr(yourField, " ")+1,2)

Ian
 
You could do the following:

Trim(Split({table.field}," ")[2])

-LB
 
Actually, I think my suggestion would not quite work. In case of double spaces, try this for the second section:

Split(Replace({table.field}," "," ")," ")[2]

It doesn't display properly here, but there are two spaces within the first set of quotes, and one within the other two.

-LB
 
i was actually looking through other threads after i posted this and i came across one and tried it and it works. i have no idea why it works though. i've never used ubound before. i'm using it for the Stop # part of the field split.

Split({oeeh1.route}," ")[Ubound(Split({oeeh1.route}," "))]
 
Unbound will return the last element in the array created by the split function, so that would work also.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top