HELP!
I'm trying to check a form for missing values. Two of the fields are required and therefore the corresponding message boxes are VBOkOnly. The other two are for warning purposes and their message boxes are VBYesNo.
First the code asks if the user wants to save the record. If the user answers Yes, the code should proceed to check for errors and allow the user to correct them. Once all of the errors are corrected a message box display "End of Yes Test" should appear. if the user answers No, a message box displaying "End of No Test" should appear. The No part is working correctly but the Yes part is only partially working.
The checks for Date and CustomerID work fine. However, if a ShipMethodID other than 1 is selected, the process stops and doesn't check the final field (ShipCost) or display the "End of Yes Test" message box.
I'm think I have an End If in the wrong place.
My code is below:
Thank you in advance.
I'm trying to check a form for missing values. Two of the fields are required and therefore the corresponding message boxes are VBOkOnly. The other two are for warning purposes and their message boxes are VBYesNo.
First the code asks if the user wants to save the record. If the user answers Yes, the code should proceed to check for errors and allow the user to correct them. Once all of the errors are corrected a message box display "End of Yes Test" should appear. if the user answers No, a message box displaying "End of No Test" should appear. The No part is working correctly but the Yes part is only partially working.
The checks for Date and CustomerID work fine. However, if a ShipMethodID other than 1 is selected, the process stops and doesn't check the final field (ShipCost) or display the "End of Yes Test" message box.
I'm think I have an End If in the wrong place.
My code is below:
Code:
Private Sub cmdTest_Click()
If MsgBox("Do You Want To Save The Sales Order?", vbDefaultButton1 + vbYesNo) = vbYes Then
If ((IsNull(Date) Or (Date) = " ")) Then
MsgBox "Please enter a date", vbOKOnly
Date.SetFocus
Exit Sub
ElseIf ((CustomerID) = 0) Then
MsgBox "Please select a customer", vbOKOnly
CustomerID.SetFocus
Exit Sub
ElseIf ((ShipMethodID) = 1) Then
If MsgBox("You haven't selected a shipping method, do you want to continue anyway?", vbDefaultButton1 + vbYesNo) = vbNo Then
ShipMethodID.SetFocus
Exit Sub
Else
End If
ElseIf ((ShipCost) = 0) Then
If MsgBox("You haven't entered a shipping cost, do you want to continue anyway?", vbDefaultButton1 + vbYesNo) = vbNo Then
ShipCost.SetFocus
Exit Sub
Else
End If
Else
MsgBox "End of Yes Test", vbOKOnly
End If
Else
MsgBox "End of No Test", vbOKOnly
End If
End Sub
Comment