I am trying to validate fields in a form, before an email is sent saying the form is OK. this is my code :
Private Sub Save_Click()
If Me.Team = "" Then
MsgBox "You must enter your Team name", "Data Validation"
Me.Team.SetFocus
ElseIf Me.Customer = "" Then
MsgBox "You must enter the Customer Name", "Data Validation"
Me.Team.SetFocus
ElseIf Me.Address = "" Then
MsgBox "Your must enter the 1st line of the address", "Data Validation"
Me.Address.SetFocus
ElseIf Me.Address1 = "" Then
MsgBox "You must enter the 2nd line of the address", "Data Validation"
Me.Address1.SetFocus
ElseIf Me.QueryContact = "" Then
MsgBox "You must enter a Contact name", "Data Validation"
Me.QueryContact.SetFocus
ElseIf Me.QueryPhone = "" Then
MsgBox "You must enter a Contact telephone number", "Data Validation"
Me.QueryPhone.SetFocus
End If
DoCmd.Save
DoCmd.SendObject , , , Me.ReqBy, , , "Invoice Requisition " & Me.HeaderID, "You have submiited an Invoice Requistion to Finance. The requistion was too " & Me.Customer & " and totalled " & Me.InvTotal & ". You will receive a further email confirming the Invoice Number, once Finance have issued the invoice.", no
DoCmd.SendObject , , , "lee.mason", , , "Invoice Requistion " & Me.HeaderID, "An invoice requisition from " & Me.ReqBy & " is waiting to be authorised.", no
End Sub
Can someone please explain why the email sends, even though some of the fields are not completed.
Thanks,
Lee.
Private Sub Save_Click()
If Me.Team = "" Then
MsgBox "You must enter your Team name", "Data Validation"
Me.Team.SetFocus
ElseIf Me.Customer = "" Then
MsgBox "You must enter the Customer Name", "Data Validation"
Me.Team.SetFocus
ElseIf Me.Address = "" Then
MsgBox "Your must enter the 1st line of the address", "Data Validation"
Me.Address.SetFocus
ElseIf Me.Address1 = "" Then
MsgBox "You must enter the 2nd line of the address", "Data Validation"
Me.Address1.SetFocus
ElseIf Me.QueryContact = "" Then
MsgBox "You must enter a Contact name", "Data Validation"
Me.QueryContact.SetFocus
ElseIf Me.QueryPhone = "" Then
MsgBox "You must enter a Contact telephone number", "Data Validation"
Me.QueryPhone.SetFocus
End If
DoCmd.Save
DoCmd.SendObject , , , Me.ReqBy, , , "Invoice Requisition " & Me.HeaderID, "You have submiited an Invoice Requistion to Finance. The requistion was too " & Me.Customer & " and totalled " & Me.InvTotal & ". You will receive a further email confirming the Invoice Number, once Finance have issued the invoice.", no
DoCmd.SendObject , , , "lee.mason", , , "Invoice Requistion " & Me.HeaderID, "An invoice requisition from " & Me.ReqBy & " is waiting to be authorised.", no
End Sub
Can someone please explain why the email sends, even though some of the fields are not completed.
Thanks,
Lee.