Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do close Snapshot viewer automatically 1

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
The below code is sending an email and attaching a Report
in Snapshot format to the email. It is working just fine
to a point. The Snapshot report is attaching correctly but
the report is also opening up in a Snapshot viewer. I want
to be able to shut the Snapshot viewer report so after the
email is sent the Snapshot viewer does not have to manually
be closed. Any advice or help? I added a DoCmd Close but
that is not closing the Viewer.

Code:
Private Sub CloseForm_Click()

If Not Forms!ECNBCNVIPfrm!cboECNLookup.Value = "" Then
Dim stDocName As String

stDocName = "ECNBCNVIPrpt-2"
If InStr(UserGroups(), "admingrp") > 0 Then
DoCmd.RunCommand acCmdSaveRecord
ElseIf InStr(UserGroups(), "entrygrp") > 0 Then
Forms!ECNBCNVIPfrm!ECN_Analyst.SetFocus
DoCmd.RunCommand acCmdSaveRecord
End If
MsgBox cboECN

DoCmd.OutputTo acOutputReport, stDocName, acFormatSNP, "C:\my documents\ECNBCNVIPrpt.snp", True

       Dim O As Outlook.Application
       Dim m As Outlook.MailItem
       Dim toEmail1 As String
       Dim toEmail2 As String
       Dim ccEmail1 As String
       Dim ccEmail2 As String
       Dim ccEmail3 As String
       Dim bccEmail1 As String
       Dim SL As String, DL As String
       SL = vbNewLine
       DL = SL & SL

Set O = CreateObject("Outlook.Application")
Set m = Outlook.CreateItem(0)
toEmail1 = "abkdees@nmhg.com"
ccEmail1 = "abkkulhy@nmhg.com"
ccEmail2 = "abkkulhy@nmhg.com"
ccEmail3 = ""
bccEmail1 = "abajacks@nmhg.com"

m.To = toEmail1
m.CC = ""
m.BCC = bccEmail1
m.Subject = "ECN #  " & Forms!ECNBCNVIPfrm![ECN Number].Value & "; This ECN is ready for SOURCING"
m.Body = "This ECN is Ready for SOURCING." & DL & _
       "ECN #  " & Forms!ECNBCNVIPfrm![ECN Number].Value & DL & _
       "ECN Description: " & Forms!ECNBCNVIPfrm!ECNDetailfrm![ECN Description].Value & DL & _
       "Comments: " & Forms!ECNBCNVIPfrm!ECNDetailfrm![Comments].Value & DL & _
       "Thank you for your help" & DL & _
       DLookup("ActualName", "ChangeFormUserNameTbl", "LoginName='" & GetCurrentUserName() & "'") & SL & _
       "ECN Analyst"

m.Attachments.Add "c:\my documents\ECNBCNVIPrpt.snp"
DoCmd.Close acReport, "ECNBCNVIPrpt.snp", acSaveNo


m.Display

On Error GoTo Err_CloseForm_Click

    DoCmd.Close acForm, "PopupEcn1"

Exit_CloseForm_Click:
    Exit Sub

Err_CloseForm_Click:
    MsgBox Err.Description
    Resume Exit_CloseForm_Click

End If

End Sub
 
Drop True from the end of this line:

DoCmd.OutputTo acOutputReport, stDocName, acFormatSNP, "C:\my documents\ECNBCNVIPrpt.snp", True

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top