If comp_date.Text = "" Or Not IsDate(comp_date) Then
MsgBox ("Please Enter Valid Complaint Date")
comp_date.SetFocus
Exit Sub
End If
If comp_desc.Text = "" Then
MsgBox ("Description Cannot Be Empty")
comp_desc.SetFocus
Exit Sub
End If
If comp_madeby.Text = "" Then
MsgBox ("Complaint Made By Cannot Be Empty")
comp_madeby.SetFocus
Exit Sub
End If
If comp_madeby.Text = "" Then
MsgBox ("Complaint Made By Cannot Be Empty")
comp_madeby.SetFocus
Exit Sub
End If
If comp_no.Text = "" Then
MsgBox ("Complaint No By Cannot Be Empty")
comp_no.SetFocus
Exit Sub
End If
If comp_status.Text = "" Then
MsgBox ("Complaint Status Cannot Be Empty")
comp_status.SetFocus
Exit Sub
End If
If comp_status.Text = "Completed" Then
If comp_attdate.Text = "" Or comp_attdate.Text = "0" Then
MsgBox ("Complaint Attended On Date Cannot Be Empty")
comp_attdate.SetFocus
Exit Sub
End If
If CDate(comp_attdate.Text) < comp_date.Text Then
MsgBox ("Complaint Attended On Date Should Be Greater Than Complaint Date.")
comp_attdate.SetFocus
Exit Sub
End If
If comp_attby.Text = "" Then
MsgBox ("Complaint Attended By Cannot Be Empty")
comp_attby.SetFocus
Exit Sub
End If
If comp_cause.Text = "" Then
MsgBox ("Complaint Cause Cannot Be Empty")
comp_cause.SetFocus
Exit Sub
End If
If comp_action.Text = "" Then
MsgBox ("Action Taken Cannot Be Empty")
comp_action.SetFocus
Exit Sub
End If
End If
'checking for duplicate complaint no
prodinstfrm.setcompcom
If prodinstfrm.comprs.RecordCount > 0 Then
prodinstfrm.comprs.MoveFirst
Do While Not prodinstfrm.comprs.EOF
If (prodinstfrm.comprs.Fields(0) = Val(comp_custph1) And prodinstfrm.comprs.Fields(1) <> comp_date) Or (prodinstfrm.comprs.Fields(0) <> Val(comp_custph1)) Then
If prodinstfrm.comprs.Fields(8) = Val(comp_no) Then
MsgBox ("This Complaint No Already Exists")
comp_no.SetFocus
Exit Sub
End If
End If
prodinstfrm.comprs.MoveNext
Loop
End If
'transfer complaintstemp data to complaints table
prodinstfrm.custcaredb.Execute ("delete * from complaints where comp_custph1='" & comp_custph1.Text & "'")
prodinstfrm.custcaredb.Execute ("insert into complaints select * from complaintstemp where comp_custph1='" & comp_custph1.Text & "'")
'transfer complaints data to complaintstemp table
prodinstfrm.custcaredb.Execute ("delete * from complaintstemp")
prodinstfrm.custcaredb.Execute ("insert into complaintstemp select * from complaints where comp_custph1='" & comp_custph1.Text & "'")