Using IIF in a report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

As a relative novice, I have got quite good at using IIf statements in my
reports. However, I can't find a way of resolving the following problem:

I need to print text according to the value of a variable LEFT([syll],1).
If LEFT([syll,1] = "0", I need to print "BGCSE"; if LEFT([syll],1) <> "0"
(but not null), I need to print "GCE"; if [syll] is null, print nothing.

Any help would be much appreciated.

Jim Jones
Ministry of Education
Botswana
 
Jim,

Try it like this in the Control Source property of a textbox on your
report...
=IIf(IsNull([syll]),Null,IIf(Left([syll],1)="0","BGCSE","GCE"))

An alternative, but similar, would be...
=IIf(IsNull([syll]),Null,IIf([syll] Like "0*","BGCSE","GCE"))
 
Jim

Another alternative would be to embed the "calculations" in your report's
underlying query.
 
Dear Steve

Many thanks for the help. The control worked first time.

This kind of help and advice is much appreciated - it saves me much time and
I learn a lot in the process.

Jim Jones
Ministry of Education
Botswana

Steve Schapel said:
Jim,

Try it like this in the Control Source property of a textbox on your
report...
=IIf(IsNull([syll]),Null,IIf(Left([syll],1)="0","BGCSE","GCE"))

An alternative, but similar, would be...
=IIf(IsNull([syll]),Null,IIf([syll] Like "0*","BGCSE","GCE"))

--
Steve Schapel, Microsoft Access MVP


Jim said:
As a relative novice, I have got quite good at using IIf statements in my
reports. However, I can't find a way of resolving the following problem:

I need to print text according to the value of a variable LEFT([syll],1).
If LEFT([syll,1] = "0", I need to print "BGCSE"; if LEFT([syll],1) <> "0"
(but not null), I need to print "GCE"; if [syll] is null, print nothing.

Any help would be much appreciated.

Jim Jones
Ministry of Education
Botswana
 
Back
Top