Private Sub btnQuit_Click()
On Error GoTo Handler
Dim LResponse As Integer
AttemptSave
If IsNull(tbJobID) Or tbJobID = "" Then
DoCmd.Close acForm, "frmMain"
'''
Exit Sub
Else
If (Nz(tbCatNo, "") = "") Then
MsgBox "The Line Number box has been left Blank.!" & vbNewLine & "This Job will be deleted when you click Exit. ", vbOKOnly + vbExclamation, "Missing"
Cancel = True
WarningsOff
tbCatNo = "DNull"
Dim deljob As Long
deljob = tbJobID
Long_Name = DLookup("Long_Name", "tblqcusers", "User_Name='" & Environ("UserName") & "'")
CurrentDb.Execute "INSERT INTO tblQCDeletedJobs ( Job_ID, User_Name, [Time], Raised_By, Line_Number) " & _
"SELECT " & deljob & " AS Expr1, '" & Long_Name & "' AS Expr2, Now() AS Expr3, '" & Raised_by & "' As Expr4, '" & tbCatNo & "' as Expr5;"
If cboxStatus <> 13 Then
cboxStatus = 14
InsertStatus
End If
WarningsOn
DoCmd.Close acForm, "frmMain"
Exit Sub
ElseIf (Nz(cboxStatus, "") = "0") And tbJobID <> "" Then
LResponse = MsgBox("Status has been left Empty!" & vbNewLine & "Please change the Status or Request Deletion !", VBOkayOnly, "Continue")
ESCMessage
'cboxStatus.SetFocus
Cancel = True
Exit Sub
Else
End If
If (Nz(tbJobID, 0) > 0) And ((Nz(cboxQueryType, "") = "") Or ((lblTitle.Caption <> "Rectification") And (Nz(cboxRequestArea, "") = "")) Or (Nz(cboxStockLoc, "") = "") Or (Nz(cboxSupplier, "") = "")) Then
LResponse = MsgBox("You can't quit while you are entering a partially created job!" & vbNewLine & "Do you wish to continue ?", vbYesNo, "Continue")
If LResponse = vbNo Then
ESCMessage
btnQuit.SetFocus
Cancel = True
cboxStatus = Nz(DLookup("Status_ID", "tblQCJobStatus", "Job_ID=" & Nz(tbJobID, 0) & " AND Status_Change=" & SQLDate(Nz(DMax("Status_Change", "tblQCJobStatus", "Job_ID=" & Nz(tbJobID, 0)), "1/1/1"))), 0)
Exit Sub
Else
End If
End If
CheckMandatoryFields
'AttemptSave
DoCmd.Close acForm, "frmMain"
End If
Exit Sub
Handler:
Call LogError(Err.Number, Err.Description, "FRMmainBtnQuit", tbJobID)
Forms!frmmain.Visible = True
Exit Sub
End Sub