Coding for IIf Statement

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.
 
K

Ken Snell \(MVP\)

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])
 
A

Al Campagna

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."
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top