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 to select correct Snapshot report based on current ECN 1

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
I am trying to save a report in snapshot mode and attached
it to an email. The first piece of code works and picks
up the correct snapshot report.

The second piece of code works but the snapshot report it
picks up is always based on the the first ECN in the
database. What I am wanting it to be is the snapshot report
based on the ECN that is currently selected. I need it
to work with the second piece of code because that is
the email code we are using throughout the database. Can
someone tell me what I need to do to get the second piece
of code to pick up the correct snapshot report based on
whatever ECN that is currently selected?


Code:
On Error GoTo Err_EmailEcn_Click
'Checks for empty field value, it not empty then proceeds
If Not 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
Me.ECN_Analyst.SetFocus
DoCmd.RunCommand acCmdSaveRecord
End If
DoCmd.SendObject acReport, stDocName, "Snapshot Format"


Else: MsgBox "Please select an ECN Number from the drop down list on the left."
End If
Exit_EmailEcn_Click:
    Exit Sub

Err_EmailEcn_Click:
    MsgBox Err.Description
    Resume Exit_EmailEcn_Click
Code:
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

DoCmd.OutputTo acOutputReport, "ECNBCNVIPrpt-2", "Snapshot Format", "ECNBCNVIPrpt.snp", , "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)

Dim X
Dim Y
toEmail1 = ""
For Each X In Split(Forms!ECNBCNVIPfrm!ECNDetailfrm![Engineering Distribution] & "", vbCrLf)
  If Trim(X & "") > "" Then
    Y = DLookup("LoginName", "FormEngMETbl", "EngME='" & X & "'")
    If Trim(Y & "") > "" Then
      toEmail1 = toEmail1 & Y & "@nmhg.com;"
    End If
  End If
Next
For Each X In Split(Forms!ECNBCNVIPfrm!ECNDetailfrm![MastDistribution] & "", vbCrLf)
  If Trim(X & "") > "" Then
    Y = DLookup("LoginName", "FormMastEngTbl", "MastEng='" & X & "'")
    If Trim(Y & "") > "" Then
      toEmail1 = toEmail1 & Y & "@nmhg.com;"
    End If
  End If
Next
For Each X In Split(Forms!ECNBCNVIPfrm!ECNDetailfrm![FabDistribution] & "", vbCrLf)
  If Trim(X & "") > "" Then
    Y = DLookup("LoginName", "FormFabEngTbl", "FabEng='" & X & "'")
    If Trim(Y & "") > "" Then
      toEmail1 = toEmail1 & Y & "@nmhg.com;"
    End If
  End If
Next
For Each X In Split(Forms!ECNBCNVIPfrm!ECNDetailfrm![PaintDistribution] & "", vbCrLf)
  If Trim(X & "") > "" Then
    Y = DLookup("LoginName", "FormPaintEngTbl", "PaintMe='" & X & "'")
    If Trim(Y & "") > "" Then
      toEmail1 = toEmail1 & Y & "@nmhg.com;"
    End If
  End If
Next
For Each X In Split(Forms!ECNBCNVIPfrm!ECNDetailfrm![Quality Distribution] & "", vbCrLf)
  If Trim(X & "") > "" Then
    Y = DLookup("LoginName", "FormQAEngTbl", "QAEng='" & X & "'")
    If Trim(Y & "") > "" Then
      toEmail1 = toEmail1 & Y & "@nmhg.com;"
    End If
  End If
Next
For Each X In Split(Forms!ECNBCNVIPfrm!ECNDetailfrm![MasterSchedulerDistribution] & "", vbCrLf)
  If Trim(X & "") > "" Then
    Y = DLookup("LoginName", "FormMasterSchedulerTbl", "MasterSchedulers='" & X & "'")
    If Trim(Y & "") > "" Then
      toEmail1 = toEmail1 & Y & "@nmhg.com;"
    End If
  End If
Next
If Forms!ECNBCNVIPfrm!ECNDetailfrm![Materials Distribution] = "Kim Dees" Then
toEmail1 = toEmail1 & "abkdees@nmhg.com;"
End If
If Forms!ECNBCNVIPfrm!ECNDetailfrm![Finance Distribution] = "Shirley Combs" Then
toEmail1 = toEmail1 & "abscombs@nmhg.com;"
End If
If Forms!ECNBCNVIPfrm!ECNDetailfrm![Sped Distribution] = "Jim Taylor" Then
toEmail1 = toEmail1 & "abjtaylo@nmhg.com;"
End If
If Forms!ECNBCNVIPfrm!ECNDetailfrm![Production Scheduling Distribution] = "Kimberly Kulhavy" Then
toEmail1 = toEmail1 & "abkkulhy@nmhg.com;"
End If
If Forms!ECNBCNVIPfrm!ECNDetailfrm![Service Engineering Distribution] = "Mark Hume" Then
toEmail1 = toEmail1 & "abmhume@nmhg.com;"
End If
If Forms!ECNBCNVIPfrm!ECNDetailfrm![ISA Distribution] = "FYI" Then
toEmail1 = toEmail1 & "kelley.johnson@sdi.com;"
End If

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 to be worked"
m.Body = "This ECN is Ready to be worked." & DL & _
       "Form # " & Forms!ECNBCNVIPfrm![ECNBCNVIP ID].Value & 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"

m.Display

On Error GoTo Err_CloseForm_Click


    DoCmd.Close acForm, "PopupEcn3"

Exit_CloseForm_Click:
    Exit Sub

Err_CloseForm_Click:
    MsgBox Err.Description
    Resume Exit_CloseForm_Click
End If
 
Hi, I am glad you got the problem solved but I am curious.

What was it? Was it the output to Snapshot or something else?

Dam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top