I have a form with the following code on the click event of a button.
Code:
Private Sub Command3_Click()
Dim Msg, Style, Title, Response, MyString
Msg = "You have entered a quantity made without marking the build complete." & Chr(13) & _
"Are you sure this is what you want to do?"
Style = vbYesNo + vbWarning
Title = "Warning"
If Me.Completed = True Then
If Me.QuantityMade > 0 Then
If Me.CompletedDate Is Not Null Then
DoCmd.Save
DoCmd.Close
Else
MsgBox "When you mark a build Complete." & Chr(13) & _
"Make sure Quantity Made and Completed Date are entered.", vbOKOnly + vbCritical, "Error"
End If
Else
MsgBox "When you mark a build Complete." & Chr(13) & _
"Make sure Quantity Made and Completed Date are entered.", vbOKOnly + vbCritical, "Error"
End If
ElseIf Me.QuantityMade > 0 Then
If Me.Completed = True Then
DoCmd.Save
DoCmd.Close
Else
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
DoCmd.Save
DoCmd.Close
Else
End If
End If
Else
DoCmd.Save
DoCmd.Close
End If
End Sub
When I enter a number greater than 0 in the quantity made but leave the completed checkbox unchecked I get the correct msgbox.
When I check the completed checkbox and leave the quantity made at 0 I also get the correct msgbox.
However, If I check the completed checkbox and have a quantity made of greater than 0, I get the runtime error on the line....
Code:
If Me.CompletedDate Is Not Null Then
This is very confusing to me because the object CompletedDate is there in the form.
I have attached the db just incase...
Open frmProduction_Schedule
Then dbl click on the record 8
midway down you will see the area where you mark the build complete, enter an amount made, and put in the CompletedDate.