Coding for IIf Statement

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

Guest

Can anyone tell me what is wrong with this statement?

=IIf(DataEntryFrm![Waive10%]=True,ItemSubFrm.Form![Total$ofItemsRequestedSubfrm].Form![Total
Approved],IIf(DataEntryFrm![Waive10%]=False,ItemSubFrm.Form![Total$ofItemsRequestedSubfrm].Form![Total Granted]))

When I run this I get #Name? in the textbox.
 
Assuming that the form that contains the textbox with this control source
expression is named DataEntryFrm:

=IIf([Waive10%]=True,ItemSubFrm.Form![Total$ofItemsRequestedSubfrm].Form![Total
Approved],ItemSubFrm.Form![Total$ofItemsRequestedSubfrm].Form![Total
Granted])
 
The #Name error means that one/or more of the controls you're referring
to, can not be located.

Avoid using any special characters in yout object names (%, $, etc) Try
Waive10Pct instead.
Also, your IIF statement is incorrect. You don't need a second IIF.
IIF(Condition = True, Value1, Value2)
not
IIF(Condition = True, Value1, IIF statement,Value2)
Value2 is called (without it's own IIF) if Waive10Pct is False.

It also looks as if you're True and False values are incorrectly called,
but we need to know more about how your form/forms are set up.,, in detail.
(Main and Subform description with form names and field names...)
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Actually, I just got it to work with this:

=IIf(Forms!DataEntryFrm![Waive10%]=True,ItemSubFrm.Form![Total$ofItemsRequestedSubfrm].Form![Total
Approved],IIf(Forms!DataEntryFrm![Waive10%]=False,ItemSubFrm.Form![Total$ofItemsRequestedSubfrm].Form![Total Granted]))

Thanks everyone for your help.

Al Campagna said:
The #Name error means that one/or more of the controls you're referring
to, can not be located.

Avoid using any special characters in yout object names (%, $, etc) Try
Waive10Pct instead.
Also, your IIF statement is incorrect. You don't need a second IIF.
IIF(Condition = True, Value1, Value2)
not
IIF(Condition = True, Value1, IIF statement,Value2)
Value2 is called (without it's own IIF) if Waive10Pct is False.

It also looks as if you're True and False values are incorrectly called,
but we need to know more about how your form/forms are set up.,, in detail.
(Main and Subform description with form names and field names...)
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."


DRMOB said:
Can anyone tell me what is wrong with this statement?

=IIf(DataEntryFrm![Waive10%]=True,ItemSubFrm.Form![Total$ofItemsRequestedSubfrm].Form![Total
Approved],IIf(DataEntryFrm![Waive10%]=False,ItemSubFrm.Form![Total$ofItemsRequestedSubfrm].Form![Total
Granted]))

When I run this I get #Name? in the textbox.
 
Back
Top