List Box - Multi-Select NEED HELP!!

G

Guest

I am stumped and need some assistance - PLEASE. New to List Boxes.
I have created two unbound list boxes on an unbound form to use as criteria
for a report. Both list boxes (lboxCategory and lboxSupplier) have two fields
CategoryID and Category and SupplierID and Supplier sorting ascending on
latter fields. The Multi-Select property is set to Extended. I have a
command button cmdPreview that I would like to use to preview the report
after selections are made. I will select two or more choices from each list
box at a time. Can anyone get me started with the code I need to make this
happen? I did see some examples using one list box, but how to do with two
or more list boxes is unclear.

Thank You
 
B

Bob Quintal

I am stumped and need some assistance - PLEASE. New to List Boxes.
I have created two unbound list boxes on an unbound form to use as
criteria for a report. Both list boxes (lboxCategory and
lboxSupplier) have two fields CategoryID and Category and
SupplierID and Supplier sorting ascending on latter fields. The
Multi-Select property is set to Extended. I have a command button
cmdPreview that I would like to use to preview the report after
selections are made. I will select two or more choices from each
list box at a time. Can anyone get me started with the code I
need to make this happen? I did see some examples using one list
box, but how to do with two or more list boxes is unclear.

Thank You
First you need to calculate the filter for the first field per the
listbox code and store to a variable.

Then you calculate the filter for the second to another variable.

After that, you concatenate the two variables and pass the result to
the docmd.openreport, using the optional WhereClause parameter

stFilter1 = "[CategoryID] IN (1,2,7,23)"
stFilter2 = "[SupplierID] IN (77,88)"

if len(stFilter1) > 0 AND len(stFilter2) > 0 then
stWhereClause = Stfilter1 & " AND " & stFilter2 .
elseif len(stFilter1) > 0 then
stWhereClause = Stfilter1
elseif len(stFilter2) > 0 then
stWhereClause = Stfilter2
else
' no filter ????
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top