Crystal Reports‎ > ‎

Split a single name field into separate fields

Our client had a Crystal Report connected to a database that contained a single field for somebody's name.  In the Crystal Report, the client wanted to split the single name field into separate name fields:   one for first name, one for middle name, one for last name, etc...
 
We solved this by creating separate Crystal Reports formulas to split the single field into separate fields with the first name, the middle name, the last name etc...
 
Our Crystal Reports formulas looked like this:
 
First name field formula:
 
Whileprintingrecords;
stringvar array Names := split({DBTR360_VIEW.PRIMARY_NAME1}," ");
If ubound(Names) >=1 then
Names [1];
 
Middle name field formula:
Whileprintingrecords;
stringvar array Names := split({DBTR360_VIEW.PRIMARY_NAME1}," ");
If ubound(Names) >=2 then
Names [2];
 
Last name field formula:
Whileprintingrecords;
stringvar array Names := split({DBTR360_VIEW.PRIMARY_NAME1}," ");
If ubound(Names) >=3 then
Names [3];
 
 
 
Comments