Hi
I have searched through the forums and although found relevant threads, none have helped me out.
Basically I have a form which has a field ("Status") that I've set as required from the sourcing table.
This form has a button that makes various changes to the data shown and one of them is to blank the required field. I then want it to complain that nothing's present if the form is closed but I'm aware that unless the field get's focus and data selected then deleted, it won't complain.
From searching other threads I've got the following VBA code in the form's BeforeUpdate section:
but nothing happens at all when the form's closed. There's not even an error message to say the code's wrong and just lets me close it leaving this field blank.
Any ideas where I'm going wrong?
TIA
I have searched through the forums and although found relevant threads, none have helped me out.
Basically I have a form which has a field ("Status") that I've set as required from the sourcing table.
This form has a button that makes various changes to the data shown and one of them is to blank the required field. I then want it to complain that nothing's present if the form is closed but I'm aware that unless the field get's focus and data selected then deleted, it won't complain.
From searching other threads I've got the following VBA code in the form's BeforeUpdate section:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Status = "" Or IsNull(Me.Status) Then
MsgBox "STATUS IS A REQUIRED FIELD", vbCritical + vbOKOnly + vbDefaultButton2, "MISSING DATA"
Me.Status.SetFocus
Cancel = True
Exit Sub
End If
End Sub
Any ideas where I'm going wrong?
TIA