G
Guest
I have a field on my form that is required for all new records created. This
is the code I have in the BeforeUpdate event on my form.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.RequestedBy) Then
MsgBox "You Must Select Your Name!"
Cancel = True
Me.RequestedBy.SetFocus
End If
End Sub
It doesn't seem to be working properly. Right now if I created a new record
and didn't fill in that field and just clicked the close button on my form I
do get the msgbox but then the form closes. Am I missing something here? It
doesn't set the focus on that field the way it's written in the code. I also
have this field flagged as required in the table. What am I doing wrong?
is the code I have in the BeforeUpdate event on my form.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.RequestedBy) Then
MsgBox "You Must Select Your Name!"
Cancel = True
Me.RequestedBy.SetFocus
End If
End Sub
It doesn't seem to be working properly. Right now if I created a new record
and didn't fill in that field and just clicked the close button on my form I
do get the msgbox but then the form closes. Am I missing something here? It
doesn't set the focus on that field the way it's written in the code. I also
have this field flagged as required in the table. What am I doing wrong?