Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Through a ListBox

Status
Not open for further replies.

Cohen227

MIS
Oct 30, 2001
8
US
Hi there! I have a multiselect ListBox on a form which I am trying to have the selections displayed as a string on my report. I was given the following code but it was a little unclear to me. I'm not sure where it goes, either. Please Help. Here is what the loop code looks like:
...
Dim varItem As Variant
dim txtTemp As String
For Each varItem in Me.ListBox.ItemsSelected
txtTemp = txtTemp & Me.ListBox.Column(ColumnNumber) & ", "
Next
txtTemp = Left(txtTemp, Len(txtTemp) - 2)
Me.TextBox = txtTemp
...

Thanks!
Brian
 
Hi Brian!

Assuming that you will be calling the report from a button click on the same form as the list box, put the code in the click event of the button prior to opening the report. There are a couple of changes though:

Dim varItem As Variant
dim strTemp As String
For Each varItem in Me.ListBox.ItemsSelected
strTemp = strTemp & Me.ListBox.Column(varItem, ColumnNumber) & ", "
Next
Me.TextBox = Left(strTemp, Len(strTemp) - 2)

TextBox should be replaced with the name of the textbox on the form where you will be storing the information. The textbox on the report which will display the information will reference that text box on the form.

hth Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top