Multi-select listbox

A

ant1983

I have a listbox on form frmEmailScheduleToClientMenu called listClient and
then a command button called cmdPreview. I want to select multiple values
and then when clicking the button open my query
qryTrainingDateForClientWithCriteria. The field there would be numClient.

I read some posts from Douglas Steele and understand it can only be done
with code. I have no idea where to start. please help
 
P

pietlinden

I have a listbox on form frmEmailScheduleToClientMenu called listClient and
then a command button called cmdPreview.  I want to select multiple values
and then when clicking the button open my query
qryTrainingDateForClientWithCriteria.  The field there would be numClient.

I read some posts from Douglas Steele and understand it can only be done
with code.  I have no idea where to start.  please help

read this:
http://www.mvps.org/access/forms/frm0007.htm

Otherwise, ask a specific question...
 
A

ant1983

Er? more specific that i have already asked? :)

OK So have looked at that code and, at my best attempt, adjusted it to the
following? Is it right and if so where do i put that code? :)

Dim frmEmailScheduleToClientMenu As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set frmEmailScheduleToClientMenu = Form! frmEmailScheduleToClientMenu
Set ctl = frm! listClient
strSQL = "Select * from listClient where [numClient]="

For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR [numClient]="
Next varItem

'Trim the end of strSQL
strSQL=left$(strSQL,len(strSQL)-12))
 

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