listbox solution

skate

Registered User.
Local time
Today, 01:19
Joined
May 22, 2002
Messages
136
Ok, I've come to the conclusion that there must not be a way to print values in my listbox in a report. I have a listbox that is filtered/populated depending on what letters I type in textbox (eg. find all entrie starting with "tri...") For each entry you can double click to open a form that lets you views the details for that entry. Now I want to print this list. I was thinking I would need some sort of loop??? All I want is to create a printout for the list generated, but I can't seem to find an answer. Maybe I should go about this a completely different way? Suggestions?
 
Use the recordsource of your listbox as the recordsource for your report.
 
If you want to get all of the items from the list box:

Code:
 Dim MyArray() As String
 
 For i = 0 To lstProducts.ListCount
 
    MyArray(i) = lstProducts.ItemData(i)
    ReDim Preserve MyArray(i)

 Next i

Will read them into a dynamic array - you can then do what you want with them.

HTH,
Patrick
 
sorry, I'm a bit of a clutz w/ this VB stuff. I guess what that does is stores the indexes of the list into the array, but then I don't know how to transfer it to a report?
 
Hi Skate,
The code will build an array of the textual values stored in the listbox.
If you want to display it on a report, this is what I would do:

1. Declare a Public variable in a module - i.e. Public strVar as string
2. Create a Listbox on the Report & set it's Row Source Type to "Value List"
3. Use the above code to get the data from the Listbox on the form
4. Use the "Join" Function on the array & assign it to your variable - strVar = Join(MyArray,";") - This will join the array into a semi colon delimited string.
5. In the Report Open event, set the ListBox rowsource to the Public variable - I.e. MyList.RowSource = strVar

If this is unclear (it is Monday) or if your having any trouble - send me a PM & I'll sort out an example for you.

Regards,
Patrick
 

Users who are viewing this thread

Back
Top Bottom