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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract Text from Field 1

Status
Not open for further replies.

kazcadman

IS-IT--Management
Apr 8, 2003
14
0
0
GB
Hi,

I need to extract part of a text field and use this as a formula.

I.e. Works order field equals "EBOF 003102 MFIN" (there are 21 spaces between number and MFIN). I am trying to write a formula which pulls out either the 003102 or the MFIN, so this field can be used in another calc.

I've used various Stringvar, instring calcs but keep getting errors. Any ideas anyone? Thanks

Kaz
 
You're headed in the right direction; you can do this using a series of InStr and StrReverse functions. But it can be a bit fiddly.

An easier solution might be something like this:

WhilePrintingRecords;
StringVar Field := {YourField};
StringVar Array Splitter := [" "];

If Length(YourField) > 0
Then Splitter := Split(Field);

Splitter[2];
//or//
Splitter[(UBound(Splitter))]

Create a formula without the blue line to display the 2nd section of the field, and create a second formula without the red line to display the last bit.

Naith
 
You could user the Mid function.

eg. Mid({your_field}, 1, 3)

1 is your starting position and 3 is how many to read over. So if you have 123456..., this formula extracts only 123.
 
Im trying to do something similar to this(see Advanced Sorting topic)

Im dealing with different part numbers, some of which begin with a letter, others begin with 2, 3, or 4 letters. I cant get them to sort properly. I think I need some way to identify the "letters" in the part numbers and use an if statement to specify what to do if there is 1 letter, 2 letters, etc.

This formula works with part numbers with 1 leading "letter'..
abs(val(right({PARTS.p_part_number},length({PARTS.p_part_number})-1)))
I then sort by this formula field. any suggestions?
 
I just looked at your other thread and the last solution offered appears to be on the money.
 
Thanks all, the Mid function worked great.... Kaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top