combine multiple textboxes in one textbox (1 Viewer)

basilyos

Registered User.
Local time
Yesterday, 20:27
Joined
Jan 13, 2014
Messages
252
hello guys

i have multiple textboxes in Report Detail and every textbox contain different data am having a problem when turn cangrow on so i decide to put all the textbox in one textbox but am not getting any data

this is my code please can someone help me to fix it

Code:
If Me.txt3 = "" Then
Me.txt_Combination = Me.txt1 & vbCrLf & Me.txt2 & vbCrLf & Me.txt4 & vbCrLf & Me.txt5 & vbCrLf & Me.txt6 & vbCrLf & Me.txt7 & vbCrLf & Me.txt8
ElseIf Me.txt6 = "" Then
Me.txt_Combination = Me.txt1 & vbCrLf & Me.txt2 & vbCrLf & Me.txt4 & vbCrLf & Me.txt5 & vbCrLf & Me.txt3 & vbCrLf & Me.txt7 & vbCrLf & Me.txt8
ElseIf Me.txt3 = "" And Me.txt6 = "" Then
Me.txt_Combination = Me.txt1 & vbCrLf & Me.txt2 & vbCrLf & Me.txt4 & vbCrLf & Me.txt5 & vbCrLf & Me.txt7 & vbCrLf & Me.txt8
End If
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:27
Joined
May 7, 2009
Messages
19,228
you should put the correct fieldname of your query or table.
put it in a Public Function inside the Report:

Code:
Public Function fnConcat(ParamArray p() As Variant) As String
	Dim elem As Variant
	Dim ret As String
	For Each elem In p
		If Trim(elem & "")<> "" Then ret = ret & elem & vbCrLf
	Next
	If Len(ret)>0 Then ret = Left(ret, Len(ret)-Len(vbCrLf))
	fnConCat = ret
End Function

Now on edit textbox txt_Combination's Control Source (Property->Data)

Control Source: =fnConcat(txt1,txt2,txt3,txt4,txt5,txt6,txt7,txt8)
 

Mark_

Longboard on the internet
Local time
Yesterday, 20:27
Joined
Sep 12, 2017
Messages
2,111
Alternate way of doing it, if this makes more sense to you.


If Me.txt1 <> "" then
Me.txt_Combination = Me.txt1 & vbCrLf
End If

If Me.txt2 <> "" then
Me.txt_Combination = Me.txt_Combination & Me.txt2 & vbCrLf
End If

If Me.txt3 <> "" then
Me.txt_Combination = Me.txt_Combination & Me.txt3 & vbCrLf
End If

If Me.txt4 <> "" then
Me.txt_Combination = Me.txt_Combination & Me.txt4 & vbCrLf
End If

ect...

Same basic logic as arnelgp's post, but lets you do any special formatting as needed.

NOTE: Unless you need them on different lines you can also just add a blank space between. Depending on what the data is and how it needs to be put together, each approach has its strengths. I like being explicit since I often need to do something special when putting together multiple fields.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:27
Joined
Feb 19, 2002
Messages
43,213
Textboxes only grow vertically and only if the section in which they are placed also has its can grow and can shrink properties set to yes as well.
 

Users who are viewing this thread

Top Bottom