IIf conditional expression

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

Guest

I have a field "Dateorder" within a record that is either blank, or has a date entry in the style mm/dd/yy. In a report I wish to generate, I would like display a response of "Your order was received on mm/dd/yy" if there is a date entry in the particular field; in the event there is no entry in the particular field, no text would be displayed at all

I have tried the following expression in the properties-control source box without success

iif([Dateorder]=is not null, "Your order was received on [Dateorder]", " "

Should I be using some other expression? Or should the appropriate expression be put in the query builder screen upon which the report is based

Any help would be greatly appreciated

Rick Kani
 
Try ...

iif(isnull([Dateorder]), " ", "Your order was received on
[Dateorder]")

-----Original Message-----
I have a field "Dateorder" within a record that is either
blank, or has a date entry in the style mm/dd/yy. In a
report I wish to generate, I would like display a response
of "Your order was received on mm/dd/yy" if there is a
date entry in the particular field; in the event there is
no entry in the particular field, no text would be
displayed at all.
I have tried the following expression in the properties-
control source box without success:
iif([Dateorder]=is not null, "Your order was received on [Dateorder]", " ")

Should I be using some other expression? Or should the
appropriate expression be put in the query builder screen
upon which the report is based?
 
Rick,

....or...
"Your order was " & IIf([Dateorder] Is Null, "not received", "received on "
& [Dateorder]) & "."

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

RickK said:
I have a field "Dateorder" within a record that is either blank, or has a
date entry in the style mm/dd/yy. In a report I wish to generate, I would
like display a response of "Your order was received on mm/dd/yy" if there
is a date entry in the particular field; in the event there is no entry in
the particular field, no text would be displayed at all.
I have tried the following expression in the properties-control source box without success:

iif([Dateorder]=is not null, "Your order was received on [Dateorder]", " ")

Should I be using some other expression? Or should the appropriate
expression be put in the query builder screen upon which the report is
based?
 
RickK said:
I have a field "Dateorder" within a record that is either blank, or has a date entry in the style mm/dd/yy. In a report I wish to generate, I would like display a response of "Your order was received on mm/dd/yy" if there is a date entry in the particular field; in the event there is no entry in the particular field, no text would be displayed at all.

I have tried the following expression in the properties-control source box without success:

iif([Dateorder]=is not null, "Your order was received on [Dateorder]", " ")

Should I be using some other expression? Or should the appropriate expression be put in the query builder screen upon which the report is based?

You can do this either in the text box or in the query.
Aside from a couple of syntax issues, the thing that you are
missing is that you have to concatenate the formatted value
to the text:

iif([Dateorder] is not null, "Your order was received on " &
Format([Dateorder], "mm/dd/yy"), "")

Alternatively, you could take advantage of the +
concatenation operator to simplify the expression:

"Your order was received on " + Format([Dateorder],
"mm/dd/yy")

If you do it in the text box, remember that the expression
must be preceeded by an = sign.
 
Back
Top