getting criteriafrom multiple selections in a list box?

jatfill

Registered User.
Local time
Today, 12:40
Joined
Jun 4, 2001
Messages
150
Hello,

I have created a form that returns a list of contacts with an outstanding balance greater than zero. the form is unbound, and the list results are being pulled from a query that returns the name & company name, and a charge/payment/balance summary... the bound column on the list box is the contactID, which is hidden to the user, they just see the name, company, and balance.

I created a query that gets all of the user's detailed information based on the record selected in the form:

WHERE (((tablename.contactID)=[Forms]![formname]![listbox]))

a report is printed based on the query once a button is pressed on the form.

The problem is, I want to be able to print a selected range of names, i.e. use the Extended multi-select feature of the list box... if a user selects 5 records, they get a report printed for each record, but my query will not return multiple results when I try to make the list box a multi-selectable one.

If I use just the single select option on the form listbox, the entire process works fine.

Anyone know what I'm doing wrong? Thanks in advance, as always!
 
I used this to achieve what you want. Basically it cycles through the listbox and adds the ID to a criteria filter for the report. Give it a try!

Dim strDocname as String
Dim Criteria as String
Dim i as Variant

strDocname="myReportName"

If IssueList.ItemsSelected.Count > 0 Then
' Build criteria string from selected items in list box.
Criteria = ""
For Each i In Me![IssueList].ItemsSelected
If Criteria <> "" Then
Criteria = Criteria & " OR "
End If
Criteria = Criteria & "[ID]=" _
& Me![IssueList].ItemData(i)
Next i
Else
MsgBox "Please select a model."
Exit Sub
End If
DoCmd.OpenReport strdocname, acPreview, , Criteria
 
That was EXACTLY what I needed... THANK YOU!!
 
having trouble

i tried using the same code u suggested but it doesnt seem to wrok for me...my listbox is unbound and the source is based on a date that is selected from a previous combobox. i cant use ID to be a bound column becoz in the database there same names with different IDs. So in my listbox it is group by name, date and symptom which is actually a list of ppl that has the same symptom more than 3 times in a day.

Now when i choose a date from the combobox, the listbox will display these names and i want to be able to multiselect the names to be inserted into the report....how do i do this is ths situation?

and i get errors when i type in the code below...
If Criteria <> "" Then

Please help soon...thanx
 
Charity,

Thank you soooo much! I've been so frustrated & you helped tremendously!


Maya,

> means greater than >
< means less than <
I had to figure it out too!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom