Nesting a group of If then & else statements in a Informix Ace Report
Posted in 1999
Topics: General Discussion
I am having trouble nesting a group of if then & else statements in a report It only takes the first (if then & else ) value and the rest are ignored. e.g. if field1 = "01" and field2 = "03" then print "bank" or if field 1 = "11" and field2 = "12" then print "JUDG" or if filed1 = "08" then print "NEXT" the first value is tested and the rest are ignored. Help Thanks sm
Your example would not compile , looks like you may use a case for you task , the if's would look like this : if field1 = "01" and field2 = "03" then print "bank" end if if field 1 = "11" and field2 = "12" then print "JUDG" end if if filed1 = "08" then print "NEXT end if Shirlene Mosley <smosley@mcbusa.com> wrote in message news:7vs8su$t3q$1@bgtnsc02.worldnet.att.net... > I am having trouble nesting a group of if then & else statements in a report > It only takes the first (if then & else ) value and the rest are ignored. > > e.g. if field1 = "01" and field2 = "03" then print "bank" or > if field 1 = "11" and field2 = "12" then print "JUDG" or > if filed1 = "08" then print "NEXT" > the first value is tested and the rest are ignored. > > Help > Thanks > sm > >
Shirlene Mosley wrote: > > I am having trouble nesting a group of if then & else statements in a report > It only takes the first (if then & else ) value and the rest are ignored. > > e.g. if field1 = "01" and field2 = "03" then print "bank" or > if field 1 = "11" and field2 = "12" then print "JUDG" or > if filed1 = "08" then print "NEXT" > the first value is tested and the rest are ignored. Mariusz's example will work. Although ACE does not support an ELSE IF construct you can fake it and make the code more readable. Thus: IF field1 = "01 AND field2 = "03" THEN PRINT "bank" ELSE IF field1 = "11" AND field2 = "12" THEN PRINT "JUDG" ELSE IF field1 = "08" THEN PRINT "NEXT" END IF END IF END IF This uses nesting as if there were an else if construct. If you prefer, this is really: IF field1 = "01 AND field2 = "03" THEN PRINT "bank" ELSE IF field1 = "11" AND field2 = "12" THEN PRINT "JUDG" ELSE IF field1 = "08" THEN PRINT "NEXT" END IF END IF END IF Art S. Kagel