IIf statement

J

jmoore

I would like one of two different statements to display on a report based on
whether one field is null. The two fields are BeginDate and EndDate. If
EndDate is null, it should read "Review Completed on: [BeginDate]. If not
null, it should read "Review Completed From [BeginDate] to [EndDate]. I
tried the IIf statement below, but it did not work.

=IIf([EndDate] Is Null,"(“Review Completed on: “ [BeginDate])",(“Review
Completed From “ & [BeginDate] & "to " & [EndDate]))

Thanks.
 
J

John Spencer

Probably the following should be your expression.

=IIf(IsNull([EndDate]),"Review Completed on: " & [BeginDate],
"Review Completed From " & [BeginDate] & " to " & [EndDate])

If this does not work as you expect, post back and tell us what the problem
is. "Does not work" is not a good description of the problem.

Do you get an error message, the wrong thing displayed, nothing displayed, or
does something else happen?

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
F

fredg

I would like one of two different statements to display on a report based on
whether one field is null. The two fields are BeginDate and EndDate. If
EndDate is null, it should read "Review Completed on: [BeginDate]. If not
null, it should read "Review Completed From [BeginDate] to [EndDate]. I
tried the IIf statement below, but it did not work.

=IIf([EndDate] Is Null,"(´Review Completed on: ´ [BeginDate])",(´Review
Completed From ´ & [BeginDate] & "to " & [EndDate]))

Thanks.

Just a helpful tip to help you get good responses when asking
questions in newsgroups.
Words like 'That didn't work' gives any potential reader who might
want to help you absolutely no useful information.
What didn't happen?
What did happen?
What did you expect to happen?
What is the exact code you wrote (copied directly from your database
and pasted here so we can see if you didn't simply mis-write the
code)?
Answers to those questions would be helpful to us .... to help you!

[BeginDate] and [EndDate] are Date/Time datatype fields?

Try this:
=IIf(IsNull([EndDate]),"Review Completed on: " & [BeginDate],"Review
Completed From " & [BeginDate] & " to " & [EndDate])
 
K

KARL DEWEY

Try this --
=IIf([EndDate] Is Null, "Review Completed on: " & [BeginDate], "Review
Completed From " & [BeginDate] & " to " & [EndDate])
 
J

jmoore

Wish I could do a "Reply to all" for such great response and tips. I
realized after trying the suggestions that I needed to write this as equals
not null. The code below displays the correct information when the two
fields match. However, when they do not, all that displays is a series of
pound signs (########). No text displays at all.

=IIf([EndDate]=[BeginDate],"Review Completed on: " & [BeginDate],"Review
Completed From " & [BeginDate] & " to " & [EndDate])

Thanks.

John Spencer said:
Probably the following should be your expression.

=IIf(IsNull([EndDate]),"Review Completed on: " & [BeginDate],
"Review Completed From " & [BeginDate] & " to " & [EndDate])

If this does not work as you expect, post back and tell us what the problem
is. "Does not work" is not a good description of the problem.

Do you get an error message, the wrong thing displayed, nothing displayed, or
does something else happen?

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
I would like one of two different statements to display on a report based on
whether one field is null. The two fields are BeginDate and EndDate. If
EndDate is null, it should read "Review Completed on: [BeginDate]. If not
null, it should read "Review Completed From [BeginDate] to [EndDate]. I
tried the IIf statement below, but it did not work.

=IIf([EndDate] Is Null,"(“Review Completed on: “ [BeginDate])",(“Review
Completed From “ & [BeginDate] & "to " & [EndDate]))

Thanks.
 
J

jmoore

Wish I could do a "Reply to all" for such great response and tips. I
realized after trying the suggestions that I needed to write this as equals
not null. The code below displays the correct information when the two
fields match. However, when they do not, all that displays is a series of
pound signs (########). No text displays at all.

=IIf([EndDate]=[BeginDate],"Review Completed on: " & [BeginDate],"Review
Completed From " & [BeginDate] & " to " & [EndDate])

Thanks.

KARL DEWEY said:
Try this --
=IIf([EndDate] Is Null, "Review Completed on: " & [BeginDate], "Review
Completed From " & [BeginDate] & " to " & [EndDate])

--
Build a little, test a little.


jmoore said:
I would like one of two different statements to display on a report based on
whether one field is null. The two fields are BeginDate and EndDate. If
EndDate is null, it should read "Review Completed on: [BeginDate]. If not
null, it should read "Review Completed From [BeginDate] to [EndDate]. I
tried the IIf statement below, but it did not work.

=IIf([EndDate] Is Null,"(“Review Completed on: “ [BeginDate])",(“Review
Completed From “ & [BeginDate] & "to " & [EndDate]))

Thanks.
 
J

jmoore

Wish I could do a "Reply to all" for such great response and tips. I
realized after trying the suggestions that I needed to write this as equals
not null. The code below displays the correct information when the two
fields match. However, when they do not, all that displays is a series of
pound signs (########). No text displays at all.

=IIf([EndDate]=[BeginDate],"Review Completed on: " & [BeginDate],"Review
Completed From " & [BeginDate] & " to " & [EndDate])

Thanks.

fredg said:
I would like one of two different statements to display on a report based on
whether one field is null. The two fields are BeginDate and EndDate. If
EndDate is null, it should read "Review Completed on: [BeginDate]. If not
null, it should read "Review Completed From [BeginDate] to [EndDate]. I
tried the IIf statement below, but it did not work.

=IIf([EndDate] Is Null,"(“Review Completed on: “ [BeginDate])",(“Review
Completed From “ & [BeginDate] & "to " & [EndDate]))

Thanks.

Just a helpful tip to help you get good responses when asking
questions in newsgroups.
Words like 'That didn't work' gives any potential reader who might
want to help you absolutely no useful information.
What didn't happen?
What did happen?
What did you expect to happen?
What is the exact code you wrote (copied directly from your database
and pasted here so we can see if you didn't simply mis-write the
code)?
Answers to those questions would be helpful to us .... to help you!

[BeginDate] and [EndDate] are Date/Time datatype fields?

Try this:
=IIf(IsNull([EndDate]),"Review Completed on: " & [BeginDate],"Review
Completed From " & [BeginDate] & " to " & [EndDate])
 
K

KARL DEWEY

Increase the horizontal width of the display box.
--
Build a little, test a little.


jmoore said:
Wish I could do a "Reply to all" for such great response and tips. I
realized after trying the suggestions that I needed to write this as equals
not null. The code below displays the correct information when the two
fields match. However, when they do not, all that displays is a series of
pound signs (########). No text displays at all.

=IIf([EndDate]=[BeginDate],"Review Completed on: " & [BeginDate],"Review
Completed From " & [BeginDate] & " to " & [EndDate])

Thanks.

KARL DEWEY said:
Try this --
=IIf([EndDate] Is Null, "Review Completed on: " & [BeginDate], "Review
Completed From " & [BeginDate] & " to " & [EndDate])

--
Build a little, test a little.


jmoore said:
I would like one of two different statements to display on a report based on
whether one field is null. The two fields are BeginDate and EndDate. If
EndDate is null, it should read "Review Completed on: [BeginDate]. If not
null, it should read "Review Completed From [BeginDate] to [EndDate]. I
tried the IIf statement below, but it did not work.

=IIf([EndDate] Is Null,"(“Review Completed on: “ [BeginDate])",(“Review
Completed From “ & [BeginDate] & "to " & [EndDate]))

Thanks.
 
J

jmoore

I can't believe it was so simple. I'm sure I tried to increase the text box
at one time and it did not work. I have the Can Grow set to Yes. Why didn't
that allow the text box to expand when needed?

KARL DEWEY said:
Increase the horizontal width of the display box.
--
Build a little, test a little.


jmoore said:
Wish I could do a "Reply to all" for such great response and tips. I
realized after trying the suggestions that I needed to write this as equals
not null. The code below displays the correct information when the two
fields match. However, when they do not, all that displays is a series of
pound signs (########). No text displays at all.

=IIf([EndDate]=[BeginDate],"Review Completed on: " & [BeginDate],"Review
Completed From " & [BeginDate] & " to " & [EndDate])

Thanks.

KARL DEWEY said:
Try this --
=IIf([EndDate] Is Null, "Review Completed on: " & [BeginDate], "Review
Completed From " & [BeginDate] & " to " & [EndDate])

--
Build a little, test a little.


:

I would like one of two different statements to display on a report based on
whether one field is null. The two fields are BeginDate and EndDate. If
EndDate is null, it should read "Review Completed on: [BeginDate]. If not
null, it should read "Review Completed From [BeginDate] to [EndDate]. I
tried the IIf statement below, but it did not work.

=IIf([EndDate] Is Null,"(“Review Completed on: “ [BeginDate])",(“Review
Completed From “ & [BeginDate] & "to " & [EndDate]))

Thanks.
 
K

KARL DEWEY

I do believe that Can Grow only works vertically.
--
Build a little, test a little.


jmoore said:
I can't believe it was so simple. I'm sure I tried to increase the text box
at one time and it did not work. I have the Can Grow set to Yes. Why didn't
that allow the text box to expand when needed?

KARL DEWEY said:
Increase the horizontal width of the display box.
--
Build a little, test a little.


jmoore said:
Wish I could do a "Reply to all" for such great response and tips. I
realized after trying the suggestions that I needed to write this as equals
not null. The code below displays the correct information when the two
fields match. However, when they do not, all that displays is a series of
pound signs (########). No text displays at all.

=IIf([EndDate]=[BeginDate],"Review Completed on: " & [BeginDate],"Review
Completed From " & [BeginDate] & " to " & [EndDate])

Thanks.

:

Try this --
=IIf([EndDate] Is Null, "Review Completed on: " & [BeginDate], "Review
Completed From " & [BeginDate] & " to " & [EndDate])

--
Build a little, test a little.


:

I would like one of two different statements to display on a report based on
whether one field is null. The two fields are BeginDate and EndDate. If
EndDate is null, it should read "Review Completed on: [BeginDate]. If not
null, it should read "Review Completed From [BeginDate] to [EndDate]. I
tried the IIf statement below, but it did not work.

=IIf([EndDate] Is Null,"(“Review Completed on: “ [BeginDate])",(“Review
Completed From “ & [BeginDate] & "to " & [EndDate]))

Thanks.
 

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