Stacey1306
Technical User
Hello,
I had previously created an invoice email blast in Access 2007, now I have upgraded to Access 2010 the code is not working. The highlighted line is where I am getting an error message.
Please advise :
Private Sub Command52_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim qd As DAO.QueryDef
Set db = CurrentDb
Set rs = db.OpenRecordset("qryEmailInvoices", dbOpenDynaset)
' qselEmailInvoiceSingleMember is the name of your new query that is the record source of your report
Set qd = db.QueryDefs("qselEmailInvoiceSingleMember")
rs.MoveFirst
Do
vMemberID = rs("MemberID")
'strSQL is the SQL view of qselEmailInvoiceSingleMember
strSQL = "SELECT * FROM qryEmailInvoices WHERE MemberID = " & vMemberID
qd.SQL = strSQL
DoCmd.SendObject acSendReport, "Email Invoices", "PDFFormat(*.pdf)", rs("Email"),_
"", "", "Northern Beaches Local Liquor Accord Membership", _
"Hello [First Name], " & vbCrLf & vbCrLf & _
"Please find the attached invoice for your Membership dues for payment." & vbCrLf & vbCrLf & _
"Please note that payment is due within 14 days of date of invoice, after which your membership may be cancelled." & vbCrLf & vbCrLf & _
"We appreciate your continued support and prompt attention to this matter." & vbCrLf & vbCrLf & _
"Kind regards" & vbCrLf & "Northern Beaches Local Liquor Accord", False
rs.MoveNext
Loop Until rs.EOF
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
I had previously created an invoice email blast in Access 2007, now I have upgraded to Access 2010 the code is not working. The highlighted line is where I am getting an error message.
Please advise :
Private Sub Command52_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim qd As DAO.QueryDef
Set db = CurrentDb
Set rs = db.OpenRecordset("qryEmailInvoices", dbOpenDynaset)
' qselEmailInvoiceSingleMember is the name of your new query that is the record source of your report
Set qd = db.QueryDefs("qselEmailInvoiceSingleMember")
rs.MoveFirst
Do
vMemberID = rs("MemberID")
'strSQL is the SQL view of qselEmailInvoiceSingleMember
strSQL = "SELECT * FROM qryEmailInvoices WHERE MemberID = " & vMemberID
qd.SQL = strSQL
DoCmd.SendObject acSendReport, "Email Invoices", "PDFFormat(*.pdf)", rs("Email"),_
"", "", "Northern Beaches Local Liquor Accord Membership", _
"Hello [First Name], " & vbCrLf & vbCrLf & _
"Please find the attached invoice for your Membership dues for payment." & vbCrLf & vbCrLf & _
"Please note that payment is due within 14 days of date of invoice, after which your membership may be cancelled." & vbCrLf & vbCrLf & _
"We appreciate your continued support and prompt attention to this matter." & vbCrLf & vbCrLf & _
"Kind regards" & vbCrLf & "Northern Beaches Local Liquor Accord", False
rs.MoveNext
Loop Until rs.EOF
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub