Print Multiselect values to a report header

snoopy92211

New member
Local time
Yesterday, 21:49
Joined
Feb 25, 2005
Messages
7
Hi folks! Here's my problem. I have a multiselect listbox named fruit on a form. (simple multiselect). The user should be able to select anywhere from none to all values. from this information, a report populates depending on what I select in my multiselect listbox. The report is populating fine, everything is working great! The only thing I can't figure out is how to get the values to list on the report header. This wouldn't be that difficult if the underlying table (from the listbox) only had one column. Although my data is bound by the primary key, Fruit ID, I want my report to actually show the corresponding fruitname.

Here's my table, fruit

Col 1:fruitid Col 2: name
1 apples
2 oranges
3 bananas

my multiselect listbox record source is:

Code:
--------------------------------------------------------------------------------

SELECT [fruit].[fruitID], [fruit].[Name] FROM [fruit] order by fruit.name;
--------------------------------------------------------------------------------


The actual VBA code for the multiselect box is:
Code:
--------------------------------------------------------------------------------

For Each varitem In Me.lstfruit.ItemsSelected
strfruit = strfruit & "," & Me.lstfruit.ItemData(varitem)
Next varitem
If Len(strfruit) = 0 Then
strfruit = "Like '*'"
Else
strfruit = Right(strfruit, Len(strfruit) - 1)
strfruit = "IN(" & strfruit & ")"
End If
--------------------------------------------------------------------------------


I even tried to have the values (the selected values from the listbox) added to a text box on the form, so I can just call the form's textbox and show the values selected on the report. But that is only showing the first value. HELP!
 

Users who are viewing this thread

Back
Top Bottom