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

Crystal Reports 11 1

Status
Not open for further replies.

lindss

Instructor
Apr 27, 2005
6
US
I have a memo field in a database with typed text in it. Users want me to extract Manufacturer Code text between the strings "Code:" and "Cost" from this memo field. There may be multiple occurrences of these substrings in each memo field. I have tried this formula and have gotten error code "A loop was evaluated more than the maximum number of times allowed."

StringVar Code := {%creatorcomments};

While Instr({%creatorcomments},"Code:")>0 Do
(
Code := ExtractString({%creatorcomments},"Code:","Cost");
);

I need help, thanks so much
 
stringvar a := {your_memo_field}; //assign the memo field to variable
numbervar P3 := ubound(split(a,"Code:"))-1; // how many codes in the memo field
stringvar array MCode; //the code looking for
numbervar b; //for loop
numbervar P1; //where is "Code:" located in a
numbervar P2; //where is "Cost:" located in a
stringvar output; // codes sperated by a comma
if P3 > 0 then
(
redim MCode[P3];
for b := 1 to P3
Do
(
P1 := instr(a,"Code:") + 6; //set start location for code
P2 := instr(a,"Cost"); // set new location of Cost
MCode := trim(mid(a,P1,(P2-P1))); // pull out current code
a := mid(a,P2+5); //strip the part of a we have already looked at
)
);
output := join(MCode,","); // join all the elements of the array for output seperated by comma

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Thank you so much for your help. I will be trying it this morning and will let you know how I do. Obviously I have a lot to learn. I can't seem to find a lot out there for advanced Crystal Reports formulas and I don't have a programming background at all. I thought about taking a programming class in Visual Basic or something to give me the programming logic. Any suggestions are appreciated. Thanks again.
 
Worked great except for a few entries that I suspect have data entry issues. I am very appreciative!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top