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!

Complex If-Then-Else formula

Status
Not open for further replies.

Rena

Programmer
May 24, 2000
69
US
Hi,

I have a formula that I can't get to work. Here it is:
StringVar FirstMiddle := ' ';
StringVar First := ' ';
StringVar Middle := ' ';
StringVar Last := ' ';

If InStr({ssemploy.empname},',') < 1 Then
If InStr({ssemploy.empname},' ') < 1 Then
Last := {ssemploy.empname}
Else
(First := Left({ssemploy.empname},InStr({ssemploy.empname},' ')) ;
Middle := Mid({ssemploy.empname},(InStr({ssemploy.empname},' ')+1)))
Else
FirstMiddle := Mid({ssemploy.empname},(InStr({ssemploy.empname},',')+2)) ;
If InStr (FirstMiddle, ' ') < 1 Then
(First := FirstMiddle ;
Last := Left({ssemploy.empname},InStr({ssemploy.empname},',')))
Else
(First := Left(FirstMiddle,InStr(FirstMiddle,' ')) ;
Middle := Mid(FirstMiddle,(InStr(FirstMiddle,' ')+1)) ;
Last := Left({ssemploy.empname},InStr({ssemploy.empname},','))) ;

First

I know that empname=Thermal Platter.
I also know that InStr({ssemploy.empname},' ') = 8. So I should be inside the Else of the 2nd If and First should = Thermal and Middle should = Platter. But I only get blank when I display either First or Middle. Anybody have any suggestions?

TIA,
Rena
 
I figured it out.

All the code after the second ELSE needs to be surrounded by ( ).

Rena
 
I suspect you need some more parentheses
Else
(
FirstMiddle := Mid({ssemploy.empname},(InStr({ssemploy.empname},',')+2)) ;
If InStr (FirstMiddle, ' ') < 1 Then
(First := FirstMiddle ;
Last := Left({ssemploy.empname},InStr({ssemploy.empname},',')))
Else
(First := Left(FirstMiddle,InStr(FirstMiddle,' ')) ;
Middle := Mid(FirstMiddle,(InStr(FirstMiddle,' ')+1)) ;
Last := Left({ssemploy.empname},InStr({ssemploy.empname},','))) ;
) ; Malcolm
 
Sorry. I guess I was just too fast for you (this time) hee hee

Rena
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top