Full Version: combine several fields in one text box
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
lisa2004
I have 3 fields, field1="Hello,", field2="How are you?", field3="My name is Lisa."
If I want 3 fields show on 1 text box control MyTextBox, I set MyTextBox recordsource
=field1 & " " & field2 " " & field3

It will show as:
Hello, How are you? My name is Lisa.

How to let it show as (with line change \n, what is the syntax here for \n)
Hello,
How are you?
My name is Lisa.

The reason for this is actually for a report.
=Trim(IIf(rootCause1=False," ",rootWhy1 & "\n " ) & IIf(rootCause2=False," ",rootWhy2 & "\n ") & IIf(rootCause3=False," ",rootWhy3 & "\n ") & IIf(rootCause4=False," ",rootWhy4 & "\n ") & IIf(rootCause5=False," ",rootWhy5))

Thanks in advance.

Lisa
Mink
The code for a carriage return is & vbCr and should work as =field1 & vbCr & field2 & vbCr & field3

HTH
Mink
lisa2004
I tested, seems not work.

code:
Private Sub Form_Current()
Me!test = [rootWhy1] & vbCr & [rootWhy2]
Me!test2 = "Test1" & vbCr & "Test2"
end sub

result:(field rootWhy1="why1", rootWhy2 ="why2")
test = why1why2
test2=Test1Test2
Mink
I am not so good at syntax, but I use the command in a email string that I got off these forums.

"ECR " & Me.ECRNumber & " has been entered by " & Me.Text29 & " and is waiting to be reviewed." & vbCr & " " & vbCr & "Click on the Link below to access the database." & vbCr & " " & vbCr & GetFullPath()

Returns

"ECR 0001 has been entered by Name and is waiting to be reviewed.

Click on the link below to access the database.

(path to database)"
ScottGem
Try vbCrLf
lisa2004
Cool, great, it worked on form code (but not under control box property)
The same reason I guess, when I applied it to my report text control recordsource


=Trim(IIf(rootCause1=False," ",rootWhy1 & vbCrLf) & IIf(rootCause2=False," ",rootWhy2 & "vbCrLf) & IIf(rootCause3=False," ",rootWhy3 & "\n ") & IIf(rootCause4=False," ",rootWhy4 & "\n ") & IIf(rootCause5=False," ",rootWhy5))

Report doesn't recognize vbCrLf. The thing is if I try to applied it to code, I have to change text box recordsource under report design mode, which may cause security permission problem.

The way I can think is to creat a form as subreport. I am not sure is there a better way?

Lisa
Larry Larsen
Hi Lisa
+Chr(13)+Chr(10) work in reports..
thumbup.gif
lisa2004
Great!!! This is a so cool place to share the ideas. Thanks for all of your response.


Lisa
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.