Private Sub Form_Unload(Cancel As Integer)
'-- Make sure at least the minimum fields are completed
On Error GoTo Err_Form_Unload
Dim MyMessage As String, ctlWithFocus As Control, Answer As Integer
MyMessage = ""
If Not Deleted Then
If Nz(Me.optStorage, 0) = 0 Then
MyMessage = "The Storage Requirements must be set!" & vbCrLf & vbCrLf & MyMessage
Set ctlWithFocus = Me.optStorage
End If
If Me.txtUnitCase = 0 Then
MyMessage = "The Units per case must be set!" & vbCrLf & vbCrLf & MyMessage
Set ctlWithFocus = Me.txtUnitCase
End If
If (Me.cboUnits & "") = "" Then
MyMessage = "The Measurement Unit must be set!" & vbCrLf & vbCrLf & MyMessage
Set ctlWithFocus = Me.cboUnits
End If
If Me.cboCategory.Column(0) = 27 Then
MyMessage = "The Expensing Category has not been set!" & vbCrLf & vbCrLf & MyMessage
Set ctlWithFocus = Me.cboCategory
End If
If (Me.txtSupplierDesc & "") = "" Then
MyMessage = "The Description has not been completed!" & vbCrLf & vbCrLf & MyMessage
Set ctlWithFocus = Me.txtSupplierDesc
End If
If (Me.txtProdName & "") = "" Then
MyMessage = "The Product Name has not been completed!" & vbCrLf & vbCrLf & MyMessage
Set ctlWithFocus = Me.txtProdName
End If
If Len(MyMessage) <> 0 Then
MyMessage = MyMessage & vbCrLf & vbCrLf & _
"Do you wish to DELETE this Product?"
Answer = MsgBox(MyMessage, vbYesNo)
If Answer = vbNo Then
ctlWithFocus.SetFocus
If (ctlWithFocus = Me.cboCategory) Or (ctlWithFocus = Me.cboUnits) Then
ctlWithFocus.Dropdown
End If
Cancel = True
Else
Cancel = Not DeleteProduct()
End If
End If
Else
Cancel = False
End If
If Not Cancel Then
If Not IsNull(Me.OpenArgs) Then
Forms(CallingForm).UpdateProductList
Forms(CallingForm).Visible = True
End If
End If
Exit_Form_Unload:
On Error Resume Next
Set ctlWithFocus = Nothing
Exit Sub
Err_Form_Unload:
Call LogError(Err.Number, Err.Description, "Form_Unload() in " & Me.Name)
Resume Exit_Form_Unload
End Sub