Multi-Select List boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
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
 

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

Back
Top