Hi. It looks to me as if you're struggling with a complicated expression and making a couple of minor errors in there. Hence dealing with it needs careful consideration of a number of the parts.
I'll start by pointing you towards an article (
Using "&" and "+" in WHERE Clause) that explains the concept of using + and &. TBF you had the basic idea but were a little off on the details.
Now, as Smiley explains in his post, only those items to the immediate left and right of the + are examined to determine if the expression should resolve to Null or not. That means, if you want a carriage return / line feed pair to be optional depending on an expression then the carriage return / line feed pair must be enclosed within parentheses. Otherwise it only operates on the CR and leaves the LF in place.
Another important point to remember is that
''
(or even
""
if you're using Access' default quote char) is quite different from Null. The first is an empty string. The second isn't even of type string at all, and can only be used with strings when coerced. So
'' + (Chr(13) & Chr(10))
resolves to
Chr(13) & Chr(10)
, whereas
Null + (Chr(13) & Chr(10))
resolves to Null.
A last point is that form and report controls typically have a value of Null when empty. Fields (String), on the other hand, can have either Null or empty string (
''
) depending on its attributes (
.Required
&
.AllowZeroLength
). So it's important to remember what you're dealing with. In your case it seems to be fields rather than controls.
Assuming your empty fields contain Nulls instead of empty strings you'll need something like :
- [Expr1] + (Chr(13) & Chr(10)) & [Expr2] + (Chr(13) & Chr(10)) & [Expr3] + (Chr(13) & Chr(10)) & ...
If the values are empty strings instead :
- [Expr1] & IIf([Expr1]>'',Chr(13) & Chr(10),'') & [Expr2] & IIf([Expr2]>'',Chr(13) & Chr(10),'') & ...
Notice this is more clumsy so I'd consider setting your fields up to contain Nulls when empty if you can.