Hi All,
I am trying to do something similar to post thread705-1137518. My problem is the sName returns "MyReportName" but the strSQL returns 'MyReportName'". Therefore, I receive an error that it cannot find MyReportName due to the punctuation. How do I make the strSQL statment retuen "MyReportName"
Thanks
Dom
I am trying to do something similar to post thread705-1137518. My problem is the sName returns "MyReportName" but the strSQL returns 'MyReportName'". Therefore, I receive an error that it cannot find MyReportName due to the punctuation. How do I make the strSQL statment retuen "MyReportName"
Thanks
Dom
Code:
Public Function SendReport(sName As String) As Boolean
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM EmailTable WHERE eReport = [COLOR=red]'" & sName & "'"[/color]
Set rs = CurrentDb.OpenRecordset[COLOR=red](strSQL)[/color]
If rs.EOF Then 'no record for that report
Set rs = Nothing
MsgBox "No email entry for that report.", vbOKOnly, "No Email"
Exit Function
End If
With rs
.MoveFirst
DoCmd.SendObject acSendReport, sName, , !eTo, !eCC, _
!eBCC, !eSubject, !eMessage, False
MsgBox "Email sent to " & !eTo & vbCrLf & !eCC & _
vbCrLf & !eBCC & ".", vbOKOnly, "Email Sent"
End With
SendReport = True
Set rs = Nothing
End Function