Thanks for your help. Keep in mind that I know very little. What I have learned is from trial and error.
I tried this and replaced my code with this in my form VB Code. It gave me the following error " Compile error: Invalid or unqualified reference" and highlists the ![Email Address] in Me.email1 = ![Email Address]
Let me give all my code from the form and from the module.
From Form:
----------------------------------------------------------
Private Sub SendEmailButton_Click()
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM emailquery WHERE email = -1"
Set rs = CurrentDb.OpenRecordset(strSQL)
With rs
Do While Not rs.EOF
Me.email1 = ![Email Address]
If ![Email Address] <> "" Then DoCmd.SendObject acSendReport, "WCRC Letter", acFormatSNP, ![Email Address], , , !eSubject, Me.eMessage & Me.eMessageFooter, False
.MoveNext
Loop
End With
End Sub
_________________________________________________________
from module named email
----------------------------------------------------------
Public Function SendReport(sName As String) As Boolean
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM emailquery WHERE eReport = '" & sName & "'"
Set rs = CurrentDb.OpenRecordset(strSQL)
If rs.EOF Then 'no record for that report
Set rs = Nothing
MsgBox "No email entry for that report.", vbOKOnly, "No Email"
Exit Function
End If
With rs
.MoveFirst
' DoCmd.SendObject acSendReport, sName, , ![Email Address], !eCC, _
' !eBbcc, !eSubject, !eMessage, False
DoCmd.SendObject acSendReport, sName, , ![Email Address], , _
, !eSubject, !eMessage, False
MsgBox "Email sent to " & ![Email Address] & vbCrLf & !eCC & _
vbCrLf & !eBcc & ".", vbOKOnly, "Email Sent"
End With
SendReport = True
Set rs = Nothing
End Function
---------------------------------------------------------
The form currently refers to a query named EmailQuery
The fields and tables used in the query are:
Field: Table:
LastName MembersInfo
FirstName MembersInfo
EmailAddress MembersInfo
email MembersInfo
ID MembersInfo
ereport email
esubject email
emessage email
-----------------------------------
This all work very good. I can sent out emails great with the attached snap.
Now, I have another table that I want to create a new record for each email I send out.
TableName = MembersEmailsSent
ID = autonumber
MemberID = ID from emailquery above
Letter Name = me.ereport from the form
DateEmailSent = Date()
----------------------------------------------------
I know my module doesnt 100% match some of the code in my form, but so far no errors. Do I have to use the module?
This is getting pretty complicated.
Thanks,
Larry