Expression Not Working on Report

K

Katherine R

The following expression is the control source for an unbound text box on a
form.

=IIf([CitationType]="Alcohol",[AlcoholLicNo],[TobaccoLicNo])

It works well on the form. But it does not work on a report. On the report
the TobaccoLicNo is returned if CitationType is other than Alcohol, but
#Error is returned if CitationType is Alcohol. What could I be doing wrong
this time?
 
A

Allen Browne

Make sure the Name property of the text box on the report is not the same as
the name of a field. For example, it must not be named CitationType,
AlcoholLicNo, or TobaccoLicNo.

In some cases, these kinds of reference only work in the context of a report
if you put a text box on the report for each of the fields it refers to. You
can set the Visible property of these text boxes to No if you wish.
 
M

Marshall Barton

Katherine said:
The following expression is the control source for an unbound text box on a
form.

=IIf([CitationType]="Alcohol",[AlcoholLicNo],[TobaccoLicNo])

It works well on the form. But it does not work on a report. On the report
the TobaccoLicNo is returned if CitationType is other than Alcohol, but
#Error is returned if CitationType is Alcohol. What could I be doing wrong
this time?


Check the name of the text box. If it's named AlcoholLicNo,
change it to something else such as txtAlcoholLicNo or
anything other than AlcoholLicNo.
 
K

Katherine R

That was the problem. Thanks to both of you!!

Allen Browne said:
Make sure the Name property of the text box on the report is not the same as
the name of a field. For example, it must not be named CitationType,
AlcoholLicNo, or TobaccoLicNo.

In some cases, these kinds of reference only work in the context of a report
if you put a text box on the report for each of the fields it refers to. You
can set the Visible property of these text boxes to No if you wish.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Katherine R said:
The following expression is the control source for an unbound text box on
a
form.

=IIf([CitationType]="Alcohol",[AlcoholLicNo],[TobaccoLicNo])

It works well on the form. But it does not work on a report. On the
report
the TobaccoLicNo is returned if CitationType is other than Alcohol, but
#Error is returned if CitationType is Alcohol. What could I be doing
wrong
this time?
 
Top