Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MultiSelect (A2k)

    Hello

    With the attached code, I am selecting multiple recipients from a list, the code is only adding one recipient, usually the last one selected.
    I'm not sure where it is going wrong and could do with a little help if possible.


    Private Sub Command36_Click()
    Dim varItem As Variant
    Dim strRecipient As String

    If Me.lstEmail.ItemsSelected.Count = 0 Then
    MsgBox "Please select one or more recipients!", vbExclamation
    Me.lstEmail.SetFocus
    Exit Sub
    End If
    For Each varItem In Me.lstEmail.ItemsSelected
    strRecipient = Me.lstEmail.ItemData(varItem)
    Next varItem

    DoCmd.SendObject , , , strRecipient, , , "test", "Testing"

    End Sub

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,328
    Thanks
    1
    Thanked 13 Times in 13 Posts

    Re: MultiSelect (A2k)

    You need to move your Docmd.SendObject to above the "Next varItem" statement, so it sends each time. YOu are cycling through the For...Next loop, but then only sending once!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MultiSelect (A2k)

    Thanks Mark.

    I'm still only getting one recipient in the "To:" box !

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: MultiSelect (A2k)

    If you want one e-mail with multiple recipients, try

    For Each varItem In Me.lstEmail.ItemsSelected
    strRecipient = strRecipient & Me.lstEmail.ItemData(varItem) & ";"
    Next varItem

    DoCmd.SendObject , , , strRecipient, , , "test", "Testing"

    This way, the recipients get concatenated.

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MultiSelect (A2k)

    Thanks Hans, thats what I was after.

    As ever, the help from all on the forum is gretly appreciated.

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,328
    Thanks
    1
    Thanked 13 Times in 13 Posts

    Re: MultiSelect (A2k)

    I'm sorry, I got confused on what your problem was. But I see Hans fixed it for you.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •