I have a form with some text boxes that filter a subform.
Data are persons with its personal information and email.
After I have filter the form.
I want to get all the emails records to send a email using the DoCMD.SendObject.
The problem that I'm having is that I can't get to the record Source of the subform.
The error that Access is giving to me is says that it requiers an object. And it higlights "sSQL" in the line when I mention the recordsource.
Can anyone help me
Data are persons with its personal information and email.
After I have filter the form.
I want to get all the emails records to send a email using the DoCMD.SendObject.
The problem that I'm having is that I can't get to the record Source of the subform.
The error that Access is giving to me is says that it requiers an object. And it higlights "sSQL" in the line when I mention the recordsource.
Can anyone help me
Code:
rivate Sub Email_Click()
Dim dbs As Database
Dim rst As Recordset
Dim sSQL As String
Dim lngPosition As Long
Dim lngCount As Long
Dim strE As String
Dim strE2 As String
Dim stremail As String
Set dbs = CurrentDb
[COLOR=Blue]Set sSQL = Me!cns_datos_sub.Form.RecordSource[/COLOR]
Set rst = dbs.OpenRecordset(sSQL)
lngCount = rst.RecordCount
For lngPosition = 1 To lngCount
With rst
'Set variables to data from a record
strE = Nz(![EMAIL])
strE2 = Nz(![Email2])
If Len(strE) Then
stremail = stremail & strE & ";"
End
If Len(strE2) Then
stremail = stremail & strE2 & ";"
End
End With
End
rst.MoveNext
Next lngPosition
DoCmd.SendObject acSendNoObject, "No Response Email", acFormatTXT, _
stremail, "", "", "This is a test.", "", False, ""
End Sub