I'm getting runtime Error 2487: The object Type argument for the action or method is blank or invalid
It triggers at line 36
I have been using this code for awhile, but all of a sudden it stopped working. Can anyone see something I have wrong?
It triggers at line 36
I have been using this code for awhile, but all of a sudden it stopped working. Can anyone see something I have wrong?
Code:
Private Sub btnAuditEmail_Click()
On Error GoTo Error
Dim strEMail As String
Dim strSubject As String
Dim strBody As String
Dim MyDB As DAO.Database
Dim rstEMail As DAO.Recordset
Dim strReportName As String
Dim myReportWhere As String
Dim myOutPutFile As String
Dim aFile As String
Dim strAtch As String
Dim strMsg As String
strMsg = "No Reject Tag Number. Please fill out the whole Reject Tag. Then try to resend"
strReportName = _
Replace(Replace("REJECT TAG#|1 PN |2", "|1", Nz(" " & _
[REJECT TAG NUMBER], " ")), "|2", Nz([Part Number] & _
" " & [Descriptive Reason], " "))
myReportWhere = "[REJECT TAG NUMBER] = [Forms]![Reject Tag Form Edit]![REJECT TAG NUMBER]"
DoCmd.OpenReport _
ReportName:="Reject Tag Report", _
View:=acViewPreview, _
WhereCondition:=myReportWhere, _
WindowMode:=acWindowNormal
myOutPutFile = "M:\Inspect\New Reject Tag Database\Reports" & _
"\" & strReportName & ".PDF"
DoCmd.OutputTo _
Objecttype:=acOutputReport, _
Outputformat:=acFormatPDF, _
Outputfile:=myOutPutFile, _
AutoStart:=False, _
Outputquality:=acExportQualityPrint
DoCmd.Close _
Objecttype:=acReport, _
ObjectName:="Reject Tag Report", _
Save:=acSaveNo
'Retrieve all E-Mail Addressess in tblEMail4
Set MyDB = CurrentDb
Set rstEMail = MyDB.OpenRecordset("Select * From tblEMail4", _
dbOpenSnapshot, dbOpenForwardOnly)
With rstEMail
Do While Not .EOF
'Build the Recipients String
strEMail = strEMail & ![EmailAddress] & ";"
.MoveNext
Loop
End With
Call MyDB.Close
Set rstEMail = Nothing
Set MyDB = Nothing
strBody = _
"Please review the attached Reject Tag."
strSubject = _
Replace(Replace("REJECT TAG#|1 PN |2", "|1", Nz(" " & _
[REJECT TAG NUMBER], " ")), "|2", Nz([Part Number] & _
" " & [Descriptive Reason], " "))
strAtch = _
"M:\Inspect\New Reject Tag Database\Reports" & _
"\" & strReportName & ".PDF"
Call SendAnEmail(olSendTo:=strEMail, _
olSubject:=strSubject, _
olEMailBody:=strBody, _
olAtchs:=strAtch, _
olDisplay:=True, _
SendAsHTML:=True)
aFile = _
"M:\Inspect\New Reject Tag Database\Reports" & _
"\" & strReportName & ".PDF"
If Len(Dir$(aFile)) > 0 Then _
Call Kill(PathName:=aFile)
Error:
MsgBox strMsg, vbCritical, "No Reject Tag number"
Exit Sub
End Sub
Comment