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

spliting string field into two variables

Status
Not open for further replies.

sbrunswik

MIS
Jan 13, 2005
14
US
Using CR10 with MYSQL, need to split a sting to create variables to do search on.
string is {lastname, firstname} table that I need to search has seperate field for each value. I tried using
Split ({lastname,firstname}, ",") but get an error message the result of a formail can not be an array

Thanks for any help
 
You'll need two separate formulas, and each has to be setup to get a subscript of the resulting array:

//@LastName
If InStr({lastname,firstname}, ",") > 0 Then
Split ({lastname,firstname}, ",")[1]
Else
{lastname,firstname};

//@FirstName
If InStr({lastname,firstname}, ",") > 0 Then
Split ({lastname,firstname}, ",")[2]
Else
"";

I included some error checking, in case you have some data in your {lastname,firstname} field that's incomplete. My example would assume that a Last Name was entered if there isn't a comma in the field.

-dave
 
Thanks for the help, If I need to Trim on the returned values, do I need to create a seperate formula?

-sonora
 
No, you can just wrap the Split() part in the Trim function:

Trim(Split({field}, ",")[1])

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top