Iif statement #Name error

10sectom

New member
Local time
Today, 23:48
Joined
Jun 19, 2012
Messages
8
I have an Iif statement on a form which results in a text string if a Yes/No field on the form is set to "True", and an alternative text string if "False". But whenever I close the application, on re-opening the field displays the #Name error instead of the text. The only way I can fix it seems to be to delete the Yes/No field holder in Design View and re-add it. I get the correct result for the remainder of the session, but as soon as I close the app I get the error again on re-opening. Its driving me mad.
 
Post your IIF statement. Also, are you checking something which could be null?
 
Thanks, Bob. Here it is:
=IIf([Bookings].[Cancelled]=True,"Réservation annulée Cancelled Booking","Confirmation de Réservation Booking Confirmation")
 
Okay, what I think is happening is that the checkbox may not be either true or false when you open the form which is why you get the error. So, let's try this:

=IIf(Nz([Bookings].[Cancelled], False)=True,"Réservation annulée Cancelled Booking","Confirmation de Réservation Booking Confirmation")
 
Thanks, Bob. But no dice.

fyi, the [Cancelled] field is in the Query that feeds the form, and the values show correctly when the query is run. The IIf statement is only in the Form itself. At first, I found the IIf statement only worked if the [Cancelled] field was dragged onto the Form, which still puzzles me as to why this should be necessary. I hadn't put it on the Form originally as I didn't want it to show, so I had to set the field's property to No Show. But of course this has only partly worked as I now have the problem described.
 
Bob, the data type is Yes/No.

I have solved the problem by putting the iif statement into the Form query. But I remain puzzled as to why it does not work when embedded directly into the Form.

Thanks for your help.
 
The problem may be that the control that the field is bound to has the same name as the field, which is what Access uses as a default. With any formulas, you need to ensure that, for any fields that are used in them, they do not share the same name as the control any of them are bound to.
 

Users who are viewing this thread

Back
Top Bottom