Getting rid of "to" when the date fields are null

P

pschoen

I am using =[FromDate1] & " to " & [ToDate1] in the control source for a date
field of a report. When there are no dates entered, without this code, I end
up with "to". I have tried =[FromDate1] & " to " + [ToDate1] If the date
fields are null, it gets rid of the "to". If the date fields have data, I get
an error in the report.
 
K

karl dewey

Try this --
=IIF([FromDate1] Is Null OR [ToDate1] Is Null, Null, [FromDate1] & "
to " & [ToDate1])
 
P

pschoen

Thanks Karl -- It worked to suppress the "to", but for some reason, now the
date wraps onto two lines in the report. I can't seem to get it to stay on
one line. The date field is horizontally aligned with another field. Could
that cause a problem?

I appreciate your help.

Phil Schoen

karl dewey said:
Try this --
=IIF([FromDate1] Is Null OR [ToDate1] Is Null, Null, [FromDate1] & "
to " & [ToDate1])
--
KARL DEWEY
Build a little - Test a little


pschoen said:
I am using =[FromDate1] & " to " & [ToDate1] in the control source for a date
field of a report. When there are no dates entered, without this code, I end
up with "to". I have tried =[FromDate1] & " to " + [ToDate1] If the date
fields are null, it gets rid of the "to". If the date fields have data, I get
an error in the report.
 
K

karl dewey

Just expand the text box horizontally.
--
KARL DEWEY
Build a little - Test a little


pschoen said:
Thanks Karl -- It worked to suppress the "to", but for some reason, now the
date wraps onto two lines in the report. I can't seem to get it to stay on
one line. The date field is horizontally aligned with another field. Could
that cause a problem?

I appreciate your help.

Phil Schoen

karl dewey said:
Try this --
=IIF([FromDate1] Is Null OR [ToDate1] Is Null, Null, [FromDate1] & "
to " & [ToDate1])
--
KARL DEWEY
Build a little - Test a little


pschoen said:
I am using =[FromDate1] & " to " & [ToDate1] in the control source for a date
field of a report. When there are no dates entered, without this code, I end
up with "to". I have tried =[FromDate1] & " to " + [ToDate1] If the date
fields are null, it gets rid of the "to". If the date fields have data, I get
an error in the report.
 
M

Marshall Barton

pschoen said:
I am using =[FromDate1] & " to " & [ToDate1] in the control source for a date
field of a report. When there are no dates entered, without this code, I end
up with "to". I have tried =[FromDate1] & " to " + [ToDate1] If the date
fields are null, it gets rid of the "to". If the date fields have data, I get
an error in the report.


You can get it by using:

=Mid((" to " + FromDate1) & (" to " + ToDate1), 5)
 

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