Hi
I have a form to indicate potential attendees at a workshop. Not all have email addresses. The form shows them all.
I created two separate queries to show (a) those with emails - to email to and (b) those without - to print off addressed letter.
I have put two buttons on the form, one for each function.
I have copied/adapted code posted here a few times for the email send but have hit a problem.
My sample data is three people, two with email addresses and one without. The queries catch this fine.
When I hit the email button I get the following message:
Invalid SQL statement: expected DELETE, INSERT, PROCEDURE, SELECT or UPDATE
Can someone point me in the right direction please?
I am using Access 2003 but in Access 2000 format.
The code I used for the email button is
code___________________
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strEmail As String
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
rs.Open "WkShAttEm", cn
With rs
Do While Not .EOF
strEmail = strEmail & .Fields("CdEm") & ";"
.MoveNext
Loop
.Close
End With
strEmail = Left(strEmail, Len(strEmail) - 1)
DoCmd.SendObject _
, _
, _
, _
("" & Me!CdEm), _
, _
, _
("" & "SWE Workshop"), _
("" & "This text needs to be worked out"), _
, _
True
_____________________
Would I be better trying to loop through the recordset that builds the form somehow using an IF CdEm is null then .... else ....?
Any help greatly appreciated.
Thanks
Malcy
I have a form to indicate potential attendees at a workshop. Not all have email addresses. The form shows them all.
I created two separate queries to show (a) those with emails - to email to and (b) those without - to print off addressed letter.
I have put two buttons on the form, one for each function.
I have copied/adapted code posted here a few times for the email send but have hit a problem.
My sample data is three people, two with email addresses and one without. The queries catch this fine.
When I hit the email button I get the following message:
Invalid SQL statement: expected DELETE, INSERT, PROCEDURE, SELECT or UPDATE
Can someone point me in the right direction please?
I am using Access 2003 but in Access 2000 format.
The code I used for the email button is
code___________________
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strEmail As String
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
rs.Open "WkShAttEm", cn
With rs
Do While Not .EOF
strEmail = strEmail & .Fields("CdEm") & ";"
.MoveNext
Loop
.Close
End With
strEmail = Left(strEmail, Len(strEmail) - 1)
DoCmd.SendObject _
, _
, _
, _
("" & Me!CdEm), _
, _
, _
("" & "SWE Workshop"), _
("" & "This text needs to be worked out"), _
, _
True
_____________________
Would I be better trying to loop through the recordset that builds the form somehow using an IF CdEm is null then .... else ....?
Any help greatly appreciated.
Thanks
Malcy