Multi-select listbox

  • Thread starter Thread starter ant1983
  • Start date Start date
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
 
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...
 
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))
 
Back
Top