email single report help

T

Thanes

I have the following code on an Send Email button: It brings up the outlook windows and attaches the report correctly but I'm still having a problem getting the email to send the SELECTED RECORD that is selected when the user pushed the EMAIL button...Any suggestions Also I currently have the report being sent as a text file... Can I change this to send the report as a word document? And how would I do that.


******************CODE*********************
Private Sub Send_Email_Click()
On Error GoTo Err_Send_Email_Click
Dim msg

If (IsNull([CAR#])) Then
msg = "Please select a record before creating an email."
MsgBox (msg)
'If no CAR# is selected, stop procedure
Exit Sub
End If

Dim varSubject As String
Dim varText As String
Dim varDocName As String
Dim varOriginator As String

varOriginator = IIf(IsNull([ORIGINATOR]), "*N/A*", [ORIGINATOR])
varSubject = "Corrective Action Request: " & [REF#]
varText = "The following report require Corrective Action: " & Chr(13) & "Ref #: " & [REF#]
varDocName = "CAR - Print/Issue to Contractor"

DoCmd.OpenReport varDocName, acViewPreview, "", "" 'Open the report"
DoCmd.SendObject acSendReport, , "Text", , , , varSubject, varText, True
DoCmd.Close

Exit_Send_Email_Click:
Exit Sub

Err_Send_Email_Click:
MsgBox Err.Description
Resume Exit_Send_Email_Click

End Sub



------------------------------------------------------------------------------------------------THANKS IN ADVANCE,

~~
Thanes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top