sam1fletcher
Registered User.
- Local time
- Today, 02:42
- Joined
- Jan 28, 2013
- Messages
- 40
Hey I have this code which works in another database to send a bulk email collecting data from a query.
not sure where the code goes wrong as it works in another program
The error is Expected SQL statement SELECT etc
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 "qryBookingDetails", cn 'Enter query name (error flags up this line)
'This code adds each feild to one string
With rs
Do While Not .EOF
strEmail = strEmail & .Fields("EmailAddress") & ";" 'enter feild name
.MoveNext
Loop
.Close
End With
not sure where the code goes wrong as it works in another program
The error is Expected SQL statement SELECT etc
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 "qryBookingDetails", cn 'Enter query name (error flags up this line)
'This code adds each feild to one string
With rs
Do While Not .EOF
strEmail = strEmail & .Fields("EmailAddress") & ";" 'enter feild name
.MoveNext
Loop
.Close
End With