Help,
Internally to our Company we issue forms that need filling in by the factory,
this form was always done my filling out one at a time every time it was needed and then emailing ppl in the company that needs to know whats going on,
so I automated it in Access, through some code I found in here,
it worked great for about 2 hours then stopped running, I cannot figure out why, can anyone help.
Here is the Code:
Private Sub Cmd_PrintMPT_Click()
On Error GoTo Err_Cmd_PrintMPT_Click
Dim stDocName, Pn As String, chimps As Integer
Dim namer, stLinkCriteria As String
Partnumber.SetFocus
Pn = Partnumber.Text
Crimps.SetFocus
chimps = Crimps.Value
If Issued.Value = False Then
'Issued.Value = True
If chimps = 2 Then
stDocName = "Rpt_2CrimpIssue"
ElseIf chimps = 3 Then
stDocName = "Rpt_3CrimpIssue"
ElseIf chimps = 4 Then
stDocName = "Rpt_4CrimpIssue"
End If
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdPrint
DoCmd.Close
'Email Stuff
stDocName = "Frm_emailssub"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'DoCmd.GoToRecord , , acFirst
Do While namer <> "End"
namer = Forms!Frm_EmailsSUB!PMail.Value
If namer = "End" Then Exit Do
MsgBox namer
DoCmd.SendObject _
, _
, _
, _
namer, _
, _
, _
"Mass Production Trial Sheet!", _
"Another MPT Sheet has been Issued on Yellow C.Card." + Chr(13) + "Partnumber: " + Pn, _
False
DoCmd.GoToRecord , , acNext
Loop
DoCmd.Close
MsgBox "All Emails Sent!", vbInformation, "Email Confirmation"
Exit Sub
ElseIf Issued.Value = True Then
If MsgBox("The MPT for " + Pn + Chr(13) + "has already been Issued." + Chr(13) + Chr(13) + "Do you wish to Issue again?", vbExclamation + vbYesNo, "Double Issue") = vbNo Then
End
ElseIf 7 Then
If chimps = 2 Then
stDocName = "Rpt_2CrimpIssue"
ElseIf chimps = 3 Then
stDocName = "Rpt_3CrimpIssue"
ElseIf chimps = 4 Then
stDocName = "Rpt_4CrimpIssue"
End If
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdPrint
DoCmd.Close
MsgBox "Reprinting Does NOT Email", vbInformation, "No Mail"
End If
End
End If
Exit Sub
Exit_Cmd_PrintMPT_Click:
DoCmd.Close
Exit Sub
Err_Cmd_PrintMPT_Click:
'MsgBox Err.Description
Resume Exit_Cmd_PrintMPT_Click
End Sub
Internally to our Company we issue forms that need filling in by the factory,
this form was always done my filling out one at a time every time it was needed and then emailing ppl in the company that needs to know whats going on,
so I automated it in Access, through some code I found in here,
it worked great for about 2 hours then stopped running, I cannot figure out why, can anyone help.
Here is the Code:
Private Sub Cmd_PrintMPT_Click()
On Error GoTo Err_Cmd_PrintMPT_Click
Dim stDocName, Pn As String, chimps As Integer
Dim namer, stLinkCriteria As String
Partnumber.SetFocus
Pn = Partnumber.Text
Crimps.SetFocus
chimps = Crimps.Value
If Issued.Value = False Then
'Issued.Value = True
If chimps = 2 Then
stDocName = "Rpt_2CrimpIssue"
ElseIf chimps = 3 Then
stDocName = "Rpt_3CrimpIssue"
ElseIf chimps = 4 Then
stDocName = "Rpt_4CrimpIssue"
End If
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdPrint
DoCmd.Close
'Email Stuff
stDocName = "Frm_emailssub"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'DoCmd.GoToRecord , , acFirst
Do While namer <> "End"
namer = Forms!Frm_EmailsSUB!PMail.Value
If namer = "End" Then Exit Do
MsgBox namer
DoCmd.SendObject _
, _
, _
, _
namer, _
, _
, _
"Mass Production Trial Sheet!", _
"Another MPT Sheet has been Issued on Yellow C.Card." + Chr(13) + "Partnumber: " + Pn, _
False
DoCmd.GoToRecord , , acNext
Loop
DoCmd.Close
MsgBox "All Emails Sent!", vbInformation, "Email Confirmation"
Exit Sub
ElseIf Issued.Value = True Then
If MsgBox("The MPT for " + Pn + Chr(13) + "has already been Issued." + Chr(13) + Chr(13) + "Do you wish to Issue again?", vbExclamation + vbYesNo, "Double Issue") = vbNo Then
End
ElseIf 7 Then
If chimps = 2 Then
stDocName = "Rpt_2CrimpIssue"
ElseIf chimps = 3 Then
stDocName = "Rpt_3CrimpIssue"
ElseIf chimps = 4 Then
stDocName = "Rpt_4CrimpIssue"
End If
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdPrint
DoCmd.Close
MsgBox "Reprinting Does NOT Email", vbInformation, "No Mail"
End If
End
End If
Exit Sub
Exit_Cmd_PrintMPT_Click:
DoCmd.Close
Exit Sub
Err_Cmd_PrintMPT_Click:
'MsgBox Err.Description
Resume Exit_Cmd_PrintMPT_Click
End Sub