IIF Statement Syntax ?

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

I have a text box on my form named Rate with the below code for the control
source.
The idea is that if the control on the form Customer Rate equals $55.00
then the text box shows the text Preferred, else if the rate is not $55.00
or is greater then the text box would show Default.
Suggestions?

IF([Customer Rate]=$55.00,"Default","Preferred")
 
Drop the $ sign, assuming that the control Customer Rate contains a numeric
value (formatted as a number, regardless of whether you're using Currency as
the display).
=IF([Customer Rate]=55,"Default","Preferred")

If the control contains a text string of "$55.00", then test against the
text string:
=IF([Customer Rate]="$55.00","Default","Preferred")


Be sure that the control named Customer Rate is either bound to a field
named Customer Rate, or that you don't have a field named Customer Rate in
the form's record source.
 
I have a text box on my form named Rate with the below code for the control
source.
The idea is that if the control on the form Customer Rate equals $55.00
then the text box shows the text Preferred, else if the rate is not $55.00
or is greater then the text box would show Default.
Suggestions?

IF([Customer Rate]=$55.00,"Default","Preferred")

1) You need to use the Immediate IF (IIF) in the control source, not
IF.
2) You have reversed the True and False part of the IIf statement if
you wish to show "Preferred" only if the value is 55.
3) Is [Customer Rate] a Text or a Number datatype?

If it's a number you must not use the $ sign.

= IIF([Customer Rate]=55.00,"Preferred","Default")

If it is Text then you must surround the value with quotes.

= IIF([Customer Rate]="$55.00","Preferred","Default")
 
The Control via the table is set to Number and format currency
The control on the form is set to currency also
The value of the control Customer Rate is expressed in $55.00 currency
format
I am getting a #Name? error




Ken Snell said:
Drop the $ sign, assuming that the control Customer Rate contains a numeric
value (formatted as a number, regardless of whether you're using Currency as
the display).
=IF([Customer Rate]=55,"Default","Preferred")

If the control contains a text string of "$55.00", then test against the
text string:
=IF([Customer Rate]="$55.00","Default","Preferred")


Be sure that the control named Customer Rate is either bound to a field
named Customer Rate, or that you don't have a field named Customer Rate in
the form's record source.

--
Ken Snell
<MS ACCESS MVP>


Dave Elliott said:
I have a text box on my form named Rate with the below code for the control
source.
The idea is that if the control on the form Customer Rate equals $55.00
then the text box shows the text Preferred, else if the rate is not $55.00
or is greater then the text box would show Default.
Suggestions?

IF([Customer Rate]=$55.00,"Default","Preferred")
 
The #Name? error (ACCESS cannot identify the source of Customer Rate)
implies that
-- there is no control on the form named Customer Rate;
-- there is a field in the form's record source named Customer Rate and
there also is a control on the form named Customer Rate, and the control
isn't bound to the field of same name;
-- there is no control and no field named Customer Rate;
-- the control named Customer Rate is on a subform if the Rate control
is on the main form, or Customer Rate is on the main form if the Rate
control is on the subform.

--
Ken Snell
<MS ACCESS MVP>

Gulf Coast Electric said:
The Control via the table is set to Number and format currency
The control on the form is set to currency also
The value of the control Customer Rate is expressed in $55.00 currency
format
I am getting a #Name? error




Ken Snell said:
Drop the $ sign, assuming that the control Customer Rate contains a numeric
value (formatted as a number, regardless of whether you're using
Currency
as
the display).
=IF([Customer Rate]=55,"Default","Preferred")

If the control contains a text string of "$55.00", then test against the
text string:
=IF([Customer Rate]="$55.00","Default","Preferred")


Be sure that the control named Customer Rate is either bound to a field
named Customer Rate, or that you don't have a field named Customer Rate in
the form's record source.

--
Ken Snell
<MS ACCESS MVP>


Dave Elliott said:
I have a text box on my form named Rate with the below code for the control
source.
The idea is that if the control on the form Customer Rate equals $55.00
then the text box shows the text Preferred, else if the rate is not $55.00
or is greater then the text box would show Default.
Suggestions?

IF([Customer Rate]=$55.00,"Default","Preferred")
 
Back
Top