how to include "hard returns" in an expression

dimebagslash

New member
Local time
Today, 21:08
Joined
Jan 25, 2011
Messages
7
I've created a text box in a form where i want to to show show all my address fields like this:

address 1
address 2
City
Post code

i dont know how to start a new line so the best i can get is:

address 1, address 2, City, Postcode.

this is the code i used:

=IIf(IsNull([Address 1]),"address...",[Address 1] & "," & " " & [Address 2] & "," & " " & [City] & "," & " " & [County] & "." & " " & [Postcode])

sorry for techno-mong language.
 
Use this (in this order):

Chr(13) & Chr(10)

Which is equivalent to a Carriage Return and Line Feed.

So, like
[Address] & Chr(13) & Chr(10) & [City]...etc.
 
And you may want to read this to see how to work with null values (down the page a bit).
 
There is also the VBA constant vbCrLf which is equivalent to chr(13) & chr(10) so you could do...
Code:
Address & vbCrLf & City
 
There is also the VBA constant vbCrLf which is equivalent to chr(13) & chr(10) so you could do...
Code:
Address & vbCrLf & City
I think the OP is doing it in a query or a control's control source.
 
There is also the VBA constant vbCrLf which is equivalent to chr(13) & chr(10) so you could do...
Code:
Address & vbCrLf & City

Yes, if this was VBA, you could do it like that. But since it is a control source you can't.
 
Look at you guys, one minute apart! You're right. Cancel the VBA. :)
 
Look at you guys, one minute apart! You're right. Cancel the VBA. :)

We're ganging up on you. (actually I had the window open for a while as I got sidetracked by a phone call and then answered)

tongueout.jpg
 
guys, thanks for the quick replies.

just to clarify i have a text box on a form. I'm using expression builder on the control source.

I tried what bob said but it brings an error about not being compatible with web based forms.

any ideas how i can get round this?
 
I don't know that you can for a web based form. There are some functions which do not work with web forms because there was no way to convert them for use on the web.
 
It seems you would have to resort to doing it in VBA using lagbolt's suggestion.

I wonder if this would work:
Code:
=Eval(Forms![COLOR=Red]FormName[/COLOR]!Address & Chr(13) & Chr(10) & Forms![COLOR=Red]FormName[/COLOR]!City & "")
Amend the bits highlighted.
 
It seems you would have to resort to doing it in VBA using lagbolt's suggestion.
You can't use VBA in a web database. You have to use macros and you are limited in the ones you can use. And functions are also limited.
 

Users who are viewing this thread

Back
Top Bottom