View Full Version : Solved: Values to Text

08-15-2008, 07:56 AM
I have a Form that need to take the data and add it to another form.

Example (UserForm2)

CmbBoxBO1 TxtqtyBo1
CmbBoxBO2 TxtqtyBo2
CmbBoxBO3 TxtqtyBo3
CmbBoxBO4 TxtqtyBo4
CmbBoxBO5 TxtqtyBo5
CmbBoxBO6 TxtqtyBo6
CmbBoxBO7 TxtqtyBo7
CmbBoxBO8 TxtqtyBo8

This is the way the form layout is. I need to pull the values from this form into 1 TxtBox in this form.

UserForm1.TxtComments.Text = UserForm2.CmbBoxBO1.Value & " " & TxtqtyBo1.txt & ";" & UserForm2.CmbBox2.Value & TxtqtyBo2 & " " ....

Until TxtqtyBo8.

If it can test for value's or just grab from visible values so it doesn't go threw all values because some will be blank.

Many cases one CmbBO1 and TxtqtyBo1 will be used, so it should just grab those and not grab the otherones.
I set it up only boxes visible are the one's with data, maybe that can help.

Any help would be great.

Bob Phillips
08-15-2008, 08:46 AM
Dim tmp As String

With UserForm2

For i = 1 To 8

If .Controls("CmbBoxBO" & i).Value <> "" Then

tmp = tmp & .Controls("CmbBoxBO" & i).Value & " "
End If
If .Controls("TxtqtyBo" & i).Text <> "" Then
tmp = tmp & .Controls("TxtqtyBo" & i).Text & ";"
End If
Next i
End With

UserForm1.TxtComments.Text = tmp

08-15-2008, 09:27 AM
That looks great xld Thanks.