T
Tom Mackay
I have a form named GroupEmail that allows user to input criterion and then
populate a List Box on the form called ListBoxClients. I want to let the user
further select records from the List Box, and compile a group email. But I
cannot get it to work properly.
Here is code to allow selected records to concatenate the email
addresses...multi-select is enabled,
-----------------------------------------
Private Sub ListBoxClients_Click()
Dim varItem As Variant
Dim strList As String
With Me!ListBoxClients
If .MultiSelect = 0 Then
strList = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(4, varItem) & ";"
Next varItem
strList = Left$(strList, Len(strList) - 1)
End If
End With
End Sub
---------------
And the code that tries to prepare email message...
Private Sub cmdEmail_Click()
On Error GoTo Err_cmdEmail_Click
Dim strEmail As String
Dim strMailSubject As String
Dim strMsg As String
strEmail = Me.strList & vbNullString
strMailSubject = "Subject"
strMsg = "Message"
DoCmd.SendObject objecttype:=acSendNoObject, _
ObjectName:=acSendNoObject, outputformat:=acFormatHTML, _
To:=strEmail, Subject:=strMailSubject, MessageText:=strMsg
Exit_cmdEmail_Click:
Exit Sub
Err_cmdEmail_Click:
MsgBox Err.Description
Resume Exit_cmdEmail_Click
End Sub
------------------
I can multi-select records in the list box, but when i try to create the
email, I get a Complie Error: method or data member not found with .strList
highlighted in cmdEmail_Click...
I have cobbled this together from various sources, and just do not
understand what's missing...
Txs,
Tom
populate a List Box on the form called ListBoxClients. I want to let the user
further select records from the List Box, and compile a group email. But I
cannot get it to work properly.
Here is code to allow selected records to concatenate the email
addresses...multi-select is enabled,
-----------------------------------------
Private Sub ListBoxClients_Click()
Dim varItem As Variant
Dim strList As String
With Me!ListBoxClients
If .MultiSelect = 0 Then
strList = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(4, varItem) & ";"
Next varItem
strList = Left$(strList, Len(strList) - 1)
End If
End With
End Sub
---------------
And the code that tries to prepare email message...
Private Sub cmdEmail_Click()
On Error GoTo Err_cmdEmail_Click
Dim strEmail As String
Dim strMailSubject As String
Dim strMsg As String
strEmail = Me.strList & vbNullString
strMailSubject = "Subject"
strMsg = "Message"
DoCmd.SendObject objecttype:=acSendNoObject, _
ObjectName:=acSendNoObject, outputformat:=acFormatHTML, _
To:=strEmail, Subject:=strMailSubject, MessageText:=strMsg
Exit_cmdEmail_Click:
Exit Sub
Err_cmdEmail_Click:
MsgBox Err.Description
Resume Exit_cmdEmail_Click
End Sub
------------------
I can multi-select records in the list box, but when i try to create the
email, I get a Complie Error: method or data member not found with .strList
highlighted in cmdEmail_Click...
I have cobbled this together from various sources, and just do not
understand what's missing...
Txs,
Tom