Even though Paul solved your problem, I rewrote your code.
BTW, you should really get away from having spaces in object names. (as in [CR ID])
Code:
Private Sub Command71_Click()
Dim Prompt As String
Dim DataIsMissing As Boolean
Prompt = "Not all required information has been filled out"
'assume the best - all data entered
DataIsMissing = False
'Check the controls
If Len(Trim(Me.[Date CR Performed] & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.txtCRDescription & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.Evaluation & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.Evaluation_performed_by & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.Evaluation_title & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.Evaluation_date & "")) = 0 Then
DataIsMissing = True
End If
If Len(Trim(Me.[CR ID] & "")) = 0 Then
DataIsMissing = True
End If
'is all data entered?
If DataIsMissing Then
MsgBox (Prompt)
Else
DoCmd.Close
End If
End Sub
Explanation:
Code:
If Len(Trim(Me.[Date CR Performed] & "")) = 0 Then
So first concatenate a null string to the value in the control to get rid of possible NULLs
Then the Trim() removes leading and trailing spaces
Then use Len() to get the length of the value in the control (if there is a value)
All you need is to know if data is there or not. So if the data is missing, set the boolean variable "DataIsMissing" to TRUE .
Using this method, I don't have to worry about NULLs or leading/trailing spaces.