Multi-Select List boxes

D

Duncan

Help! I would like to run an access report from a multiselect listbox. I can
retrieve the multiple field identifiers I want but I can't figure out how to
build the SQL with the concatenated field identifiers. I'd like to stay away
from DAO/ADO because some users will not have the correct references selected
and won't know how to find them. Also, they work with many different versions
of Access. Can SQL be written/concatenated to build a query and then a
report generated from that string? Thanks to anyone who can help!
 
J

Jörg Ackermann

Duncan said:
Help! I would like to run an access report from a multiselect
listbox. I can retrieve the multiple field identifiers I want but I
can't figure out how to build the SQL with the concatenated field
identifiers. I'd like to stay away from DAO/ADO because some users
will not have the correct references selected and won't know how to
find them. Also, they work with many different versions of Access.
Can SQL be written/concatenated to build a query and then a report
generated from that string? Thanks to anyone who can help!

In the report OnOpen-Event you can do:

sql = "select * from table where id IN ( "
for each item in Forms!YourForm!listbox.itemselected
sql = sql & Forms!YourForm!listbox.itemdata(item) & ", "
next
sql = left(sql, len(sql)-2) & " );"

Me.RowSource = sql

Acki
 
Top