I thought I had this one solved but I need some advice! I have the following code placed in on my form:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String, strTitle As String
strMsg = "Please enter a "
strTitle = " Missing Entry"
If IsNull(Me![Reason for Modification]) Then
MsgBox strMsg & "Reason for Modification", vbInformation + vbOKOnly, strTitle
Me![Reason for Modification].SetFocus
Cancel = True
End If
If IsNull(Me![txtEquipmentID]) Then
MsgBox strMsg & "Equipment ID", vbInformation + vbOKOnly, strTitle
Me![txtEquipmentID].SetFocus
Cancel = True
End If
If IsNull(Me![Position]) Then
MsgBox strMsg & "Position", vbInformation + vbOKOnly, strTitle
Me![Position].SetFocus
Cancel = True
End If
End Sub
I am trying to force the user to enter values into those three fields. My problem is that if a field is left blank and you press the exit button, the message box pops up perfectly directing the user that they have left it blank but the form closes, not allowing the user to go back and correct the empty field. I don't know if I'm missing something, or need something else on my code for the exit button (which I made with the wizard).....
Any ideas?

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String, strTitle As String
strMsg = "Please enter a "
strTitle = " Missing Entry"
If IsNull(Me![Reason for Modification]) Then
MsgBox strMsg & "Reason for Modification", vbInformation + vbOKOnly, strTitle
Me![Reason for Modification].SetFocus
Cancel = True
End If
If IsNull(Me![txtEquipmentID]) Then
MsgBox strMsg & "Equipment ID", vbInformation + vbOKOnly, strTitle
Me![txtEquipmentID].SetFocus
Cancel = True
End If
If IsNull(Me![Position]) Then
MsgBox strMsg & "Position", vbInformation + vbOKOnly, strTitle
Me![Position].SetFocus
Cancel = True
End If
End Sub
I am trying to force the user to enter values into those three fields. My problem is that if a field is left blank and you press the exit button, the message box pops up perfectly directing the user that they have left it blank but the form closes, not allowing the user to go back and correct the empty field. I don't know if I'm missing something, or need something else on my code for the exit button (which I made with the wizard).....
Any ideas?
