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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using multiple selections from list box to show in report

Status
Not open for further replies.

mcloud

Programmer
Sep 20, 2000
5
0
0
US
I have created a list box on a form, created a box to show the selections using VBA under (event procedure) in properties of the list box but I need to use the items selected only on a report and perform calculations with these multiple selections.
Once I figure this out I will have several list boxes on the form and will need to use all of those multiple selections as well. I can make the selections show up but they are all together in one box and I can't perform any calculated fields with the selections.
any one out there to help???
 
I know of one way, maybe not the best.
Create a query using that has the fields you need.
Have the report look at the query.
Then have the "Criteria" of field that looks at the listbox get the data from a function.
The function looks at the forms List box and gets all of the selections.

here is a simple function.
It does not work yet but its a start.

Public Function GetListboxData()
Dim a As Integer
GetListboxData = ""
For a = 1 To Forms!form1!List0.ListCount - 1
If Forms!form1!List0.Selected(a) Then
GetListboxData = Chr$(34) & Forms!form1!List0.Column(1) & Chr$(34) & " OR " & GetListboxData
End If
Next
GetListboxData = Left(GetListboxData, Len(GetListboxData) - 4)
End Function






DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top