add a line between two fields

J

Jessica

In Access 2002, I can join two fields and add chr(13) & chr(10) in between so
that the second field will appear on the second line. I don't want to put
the two fields in two separate text boxes because sometimes one of the fields
is null. When I try to view the report in Access 2003, the report won't show
with an error saying that it doesn't recognize chr(13). Is there another way
to add a carriage return in both Access 2002 and Access 2003?
 
K

Ken Snell [MVP]

Using Chr(13) & Chr(10) is the right way to go. If you're getting that
error, you may have a syntax problem in your control source expression, or
you may have a references problem. Post the control source expression that
you're using.
 
J

Jessica

Hi Ken,

Thanks for responding. The control source expression used is as follows:

IIf(IsNull([Add_Title]),[Comments],[Add_Title] &
IIf(IsNull([Comments]),"",Chr(13) & Chr(10) & [Comments]))

What I want the text box to show is that if both [Add_Title] and [Comments]
are not null, print them in separate lines. If either one is null, just
print the other one in the first line.

Thanks again for your assistance.

Jessica
 
K

Ken Snell [MVP]

Use a trick that takes advantage of how Null works with + operator:

="" & ([Add_Title] + Chr(13) + Chr(10)) & [Comments]

--

Ken Snell
<MS ACCESS MVP>


Jessica said:
Hi Ken,

Thanks for responding. The control source expression used is as follows:

IIf(IsNull([Add_Title]),[Comments],[Add_Title] &
IIf(IsNull([Comments]),"",Chr(13) & Chr(10) & [Comments]))

What I want the text box to show is that if both [Add_Title] and
[Comments]
are not null, print them in separate lines. If either one is null, just
print the other one in the first line.

Thanks again for your assistance.

Jessica

Ken Snell said:
Using Chr(13) & Chr(10) is the right way to go. If you're getting that
error, you may have a syntax problem in your control source expression,
or
you may have a references problem. Post the control source expression
that
you're using.
 
K

Ken Snell [MVP]

FYI... this suggestion will put a carriage return and line feed at the end
of the [Add_Title] text, even if [Comments] is Null. If that is not your
desire, then the expression does need to be a bit more complex:

= [Add_Title] & IIf(Len([Add_Title] & "")=0,"",Chr(13) & Chr(10)) &
[Comments]

--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
Use a trick that takes advantage of how Null works with + operator:

="" & ([Add_Title] + Chr(13) + Chr(10)) & [Comments]

--

Ken Snell
<MS ACCESS MVP>


Jessica said:
Hi Ken,

Thanks for responding. The control source expression used is as follows:

IIf(IsNull([Add_Title]),[Comments],[Add_Title] &
IIf(IsNull([Comments]),"",Chr(13) & Chr(10) & [Comments]))

What I want the text box to show is that if both [Add_Title] and
[Comments]
are not null, print them in separate lines. If either one is null, just
print the other one in the first line.

Thanks again for your assistance.

Jessica

Ken Snell said:
Using Chr(13) & Chr(10) is the right way to go. If you're getting that
error, you may have a syntax problem in your control source expression,
or
you may have a references problem. Post the control source expression
that
you're using.

--

Ken Snell
<MS ACCESS MVP>

In Access 2002, I can join two fields and add chr(13) & chr(10) in
between
so
that the second field will appear on the second line. I don't want to
put
the two fields in two separate text boxes because sometimes one of the
fields
is null. When I try to view the report in Access 2003, the report
won't
show
with an error saying that it doesn't recognize chr(13). Is there
another
way
to add a carriage return in both Access 2002 and Access 2003?
 
J

Jessica

Thanks a million! It works great. Just one most question - why do we check
whether Len([Add_Title] & "")=0? Can we just check Len([Add_Title])=0?

Jessica

Ken Snell said:
FYI... this suggestion will put a carriage return and line feed at the end
of the [Add_Title] text, even if [Comments] is Null. If that is not your
desire, then the expression does need to be a bit more complex:

= [Add_Title] & IIf(Len([Add_Title] & "")=0,"",Chr(13) & Chr(10)) &
[Comments]

--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
Use a trick that takes advantage of how Null works with + operator:

="" & ([Add_Title] + Chr(13) + Chr(10)) & [Comments]

--

Ken Snell
<MS ACCESS MVP>


Jessica said:
Hi Ken,

Thanks for responding. The control source expression used is as follows:

IIf(IsNull([Add_Title]),[Comments],[Add_Title] &
IIf(IsNull([Comments]),"",Chr(13) & Chr(10) & [Comments]))

What I want the text box to show is that if both [Add_Title] and
[Comments]
are not null, print them in separate lines. If either one is null, just
print the other one in the first line.

Thanks again for your assistance.

Jessica

:

Using Chr(13) & Chr(10) is the right way to go. If you're getting that
error, you may have a syntax problem in your control source expression,
or
you may have a references problem. Post the control source expression
that
you're using.

--

Ken Snell
<MS ACCESS MVP>

In Access 2002, I can join two fields and add chr(13) & chr(10) in
between
so
that the second field will appear on the second line. I don't want to
put
the two fields in two separate text boxes because sometimes one of the
fields
is null. When I try to view the report in Access 2003, the report
won't
show
with an error saying that it doesn't recognize chr(13). Is there
another
way
to add a carriage return in both Access 2002 and Access 2003?
 
K

Ken Snell [MVP]

If [Add_Title] is Null, then the result of the Len function on it is Null.
By concatenating the field with the empty string, you convert a Null to an
empty string, whose length is 0. This catches an empty value, whether it's a
Null or an empty string.
--

Ken Snell
<MS ACCESS MVP>



Jessica said:
Thanks a million! It works great. Just one most question - why do we
check
whether Len([Add_Title] & "")=0? Can we just check Len([Add_Title])=0?

Jessica

Ken Snell said:
FYI... this suggestion will put a carriage return and line feed at the
end
of the [Add_Title] text, even if [Comments] is Null. If that is not your
desire, then the expression does need to be a bit more complex:

= [Add_Title] & IIf(Len([Add_Title] & "")=0,"",Chr(13) & Chr(10)) &
[Comments]

--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
Use a trick that takes advantage of how Null works with + operator:

="" & ([Add_Title] + Chr(13) + Chr(10)) & [Comments]

--

Ken Snell
<MS ACCESS MVP>


Hi Ken,

Thanks for responding. The control source expression used is as
follows:

IIf(IsNull([Add_Title]),[Comments],[Add_Title] &
IIf(IsNull([Comments]),"",Chr(13) & Chr(10) & [Comments]))

What I want the text box to show is that if both [Add_Title] and
[Comments]
are not null, print them in separate lines. If either one is null,
just
print the other one in the first line.

Thanks again for your assistance.

Jessica

:

Using Chr(13) & Chr(10) is the right way to go. If you're getting
that
error, you may have a syntax problem in your control source
expression,
or
you may have a references problem. Post the control source expression
that
you're using.

--

Ken Snell
<MS ACCESS MVP>

In Access 2002, I can join two fields and add chr(13) & chr(10) in
between
so
that the second field will appear on the second line. I don't want
to
put
the two fields in two separate text boxes because sometimes one of
the
fields
is null. When I try to view the report in Access 2003, the report
won't
show
with an error saying that it doesn't recognize chr(13). Is there
another
way
to add a carriage return in both Access 2002 and Access 2003?
 
Top