I want to start out saying I am a novice code writer. I am trying to send a report via email based on each supplier. The code below is what I am using. I need to base recordset on Form, report generated is based on the supplier number on that form so as to only create a single report.
This is Access 2000, with Windows 2000
It is throwing error "Object variable or With Block variable not set"
The error happens on "Do While rst.EOF = False"
Any Help here is greatly appreaciated.
NICK
This is Access 2000, with Windows 2000
Code:
Private Sub EMAIL_Click()
On Error GoTo Err_EMAIL_Click
DoCmd.OpenForm "Email", acNormal
Dim rst As DAO.Recordset
Dim stDocName As String
Dim strSendTo As String
Dim strSubject As String
Dim strMessageText As String
Set rst = Me.Recordset
Do While rst.EOF = False
stDocName = "Request for Updated PO Info EMAIL"
strSendTo = [Report_Request for Updated PO Info EMAIL].Supplier_Email
strSubject = "Wesco Distribution Shipping Update Report"
strMessageText = "To: " & [Report_Request for Updated PO Info EMAIL].Supplier_Contact_Name & vbCrLf _
& "" & vbCrLf _
& "Attached is a Shipping Update Report for certain PO numbers." & vbCrLf _
& "" & vbCrLf _
& "Please review the attached report and reply back to this email with the requested information." & vbCrLf _
& "" & vbCrLf _
& "Thank you," & vbCrLf _
& "" & vbCrLf _
& "Wesco Distribution Expediting Department "
DoCmd.SendObject acSendReport, stDocName, acFormatRTF, strSendTo, , , strSubject, strMessageText
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
DoCmd.Close acForm, "Email", acSaveYes
Exit_EMAIL_Click:
Exit Sub
Err_EMAIL_Click:
MsgBox Err.Description
Resume Exit_EMAIL_Click
End Sub
The error happens on "Do While rst.EOF = False"
Any Help here is greatly appreaciated.
NICK
Comment