Concatenating Fields

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

I'm trying to concatenate address fileds on a report to print on three
separate lines. I can connect them with noo problem but, how do code a "hard
return" to start a new line on the report within the code string.
 
= "This is line 1." & chr(13) & chr(10) & "This is line 2."





Personally, I would make them three separate controls (one for each line)
and make the "can shrink"=true.



[Address1]

[Address2]

=[City] & ", " & [Sate] & " " & [Zip]
 
Or "This is line1." & vbcrlf & "This is line2."
Does the same thing, only cleaner and a less experienced programmer would
more likely understand the intrinsic constant than ASCII character conversion.

Rick B said:
= "This is line 1." & chr(13) & chr(10) & "This is line 2."





Personally, I would make them three separate controls (one for each line)
and make the "can shrink"=true.



[Address1]

[Address2]

=[City] & ", " & [Sate] & " " & [Zip]










--
Rick B



Jeff said:
I'm trying to concatenate address fileds on a report to print on three
separate lines. I can connect them with noo problem but, how do code a "hard
return" to start a new line on the report within the code string.
 
Klatuu,

Well, it doesn't really do the same thing. vbCrLf is applicable in a
VBA procedure, but not in the context which I imagine is required here.
Like Rick B, I would assume that Jeff is doing this either in a
calculated field in his query, or in the control source of a textbox on
his report, and in these cases the Chr(13) & Chr(10) syntax is the way
to go.
 
Steve,

You are incorrect. vbCrLf is exactly the same as chr(13) & chr(10). Go to
your immediate window and try it

?vbcrlf = chr(13) & chr(10)
True
 
Also, check Visual Basic Help for Miscellaneous Constants:

vbCrLf Chr(13) + Chr(10) Carriage return–linefeed combination
 
Klatuu,

You are incorrect. You didn't read my post carefully enough.

Make a query, and try putting in a calculated field like this...
[OneField] & vbCrLf & [AnotherField]
Doesn't work, does it?
Now do it like this...
[OneField] & Chr(13) & Chr(10) & [AnotherField]
Now it works, eh?

Put an unbound textbox on a form or report, and in its Control Source
put like this...
=[OneField] & vbCrLf & [AnotherField]
Now do it like this...
=[OneField] & Chr(13) & Chr(10) & [AnotherField]
Now it works, eh?

vbCrLf is not exactly the same as Chr(13) & Chr(10), is it?
 
I stand corrected. Apparently, in some contexts ie other than VBA, it does
not understand the constant.
Now lets discuss your smart ass attitude, you can point out another's error
without being rude. I appreciate learning something new, but I don't
appreciate the tone with which you delivered it. Try being a little nicer if
you would, please.

Steve Schapel said:
Klatuu,

You are incorrect. You didn't read my post carefully enough.

Make a query, and try putting in a calculated field like this...
[OneField] & vbCrLf & [AnotherField]
Doesn't work, does it?
Now do it like this...
[OneField] & Chr(13) & Chr(10) & [AnotherField]
Now it works, eh?

Put an unbound textbox on a form or report, and in its Control Source
put like this...
=[OneField] & vbCrLf & [AnotherField]
Now do it like this...
=[OneField] & Chr(13) & Chr(10) & [AnotherField]
Now it works, eh?

vbCrLf is not exactly the same as Chr(13) & Chr(10), is it?

--
Steve Schapel, Microsoft Access MVP
Steve,

You are incorrect. vbCrLf is exactly the same as chr(13) & chr(10). Go to
your immediate window and try it

?vbcrlf = chr(13) & chr(10)
True
 
Back
Top