How do I fix #Name? error in IIF form display expression?

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

I have a form which displays data from three related tables. I want to
display different text if the gender code is "M" or "F" I have tested the
logic in a query and it works as expected, but when I place it in the control
source for the text box on the form, I just get the #Name? error. The data
from the two of the files displays as expected, when I didn't condition the
value, it displayed what I expected, but when I enter the expression - no
joy. Any ideas? Thanks.
 
Make sure the Name property of the text box is not the same as the name of a
field. Access gets confused if it has the same Name as a field, but is bound
to something else.

Did you include the equal sign at the start of your expression?

What is the expression? Could be it erroneous (e.g. missing some quotes)?

Does the problem only occur if your field is Null? Or only at a new record?
Or only if there are no records?
 
I set up new names on the form for each of the fields that trying to
condition the output on. There are six fields that display one of two values
depending on whether the student (I'm with a high school) is a boy or girl.
Actually, whether the student is a boy, or not a boy!

The expression is as follows:
=IIf([Gender]="M",[EM-Boys-Main],[EM-Girls-Main])

This one I entered manually, but I get the same results when I use the
builder box. I should probably point out that I'm an ancient programmer, but
relatively new to Access.

The problem occurs whether or not the field is Null.
 
Allen it's getting late here. I'm near Chicago in the U.S. don't know if this
forum shows that anywhere. I appreciate any guidance you can provide, but I
won't see it until the (my) morning.

Thanks so much.

Jim
 
Break the problem down.

Try:
=[EM-Boys-Main]

If that works, try:
=[EM-Girls-Main]

Then:
=[Gender]

If all 3 work, and Gender shows an M (not a numeric value), then your
expression should work.

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

Reply to group, rather than allenbrowne at mvps dot org.
Jim said:
I set up new names on the form for each of the fields that trying to
condition the output on. There are six fields that display one of two
values
depending on whether the student (I'm with a high school) is a boy or
girl.
Actually, whether the student is a boy, or not a boy!

The expression is as follows:
=IIf([Gender]="M",[EM-Boys-Main],[EM-Girls-Main])

This one I entered manually, but I get the same results when I use the
builder box. I should probably point out that I'm an ancient programmer,
but
relatively new to Access.

The problem occurs whether or not the field is Null.



Allen Browne said:
Make sure the Name property of the text box is not the same as the name
of a
field. Access gets confused if it has the same Name as a field, but is
bound
to something else.

Did you include the equal sign at the start of your expression?

What is the expression? Could be it erroneous (e.g. missing some quotes)?

Does the problem only occur if your field is Null? Or only at a new
record?
Or only if there are no records?
 
Back
Top