USING BUTTON ON FORM TO SEND EMAIL message

L

Linda in Iowa

Still having problems with my code
A button on my form opens my default email program and inserts the email
address, subject, and message:
Here is the code to do that and it works fine.

Me.EMAIL = Replace(Me.EMAIL, "http://", "mailto:")
DoCmd.SendObject acSendNoObject, , , Me!EMAIL, strCC, , "subject goes
here", "message goes here"

The form contains the records from a query based on a field that matches a
date input by the user.
I have added code just before the previous code to cycle through the records
and add all email addresses so only one email needs to be sent instead of
sending each one individually. Now when I click the button I get an
"Invalid SQL statement; expected Delete, Insert, Procedure, Select or
Update. The only SQL is on the query. Here is the SQL from the query:

SELECT MBRS.ExpDate, MBRS.LastName, MBRS.FirstName, MBRS.Address, MBRS.City,
MBRS.State, MBRS.ZIP, MBRS.Memtype, MBRS.Email
FROM MBRS
WHERE (((MBRS.ExpDate)=[enter expiration date]) AND ((MBRS.Email) Is Not
Null))
ORDER BY MBRS.LastName;

Here is the code that was added to add all email addresses:

Dim rst As ADODB.Recordset
Dim strCC As String
Set rst = New ADODB.Recordset
rst.Open "qrymemexpnotice", CurrentProject.Connection, adOpenStatic,
adLockOptimistic
With rst
If .RecordCount > 0 Then
Do Until .EOF
If Not IsNull("email") Then
strCC = strCC & ("email") & ";"
End If
.MoveNext
Loop
End If
.Close
End With
Set rst = Nothing
Any suggestions on what is causing the Invalid SQL statement error?

Where would we be without all the fantastic help? Thanks everyone.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top