Before update event

D

Daniel

I'm trying to use a before update event to stop the user from entering certain information before a specific field is filled. I came up with the following code:

Private Sub DMU_Signature_BeforeUpdate(Cancel As Integer)
If IsNull(Forms![Drawing Management Frm]![Drawing History Frm sous-formulaire]![Drawing Status Tbl subform].Form![Lead Date]) Then
MsgBox "You cannot enter a DMU Signature until the Lead Date is entered"
Me.DMU_Signature = Null
End If
End Sub

the problem is that is still creates an entry in the subform (a blank entry but an entry none the less). How can I simply stop a entry from being created altogether if the [Lead Date] field is empty/null?

Thank you

Daniel
 
L

Lynn Trapp

Add the following instead of the Me.DMU_Signature = Null:

Cancel = True
Me.Undo

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Daniel said:
I'm trying to use a before update event to stop the user from entering
certain information before a specific field is filled. I came up with the
following code:
Private Sub DMU_Signature_BeforeUpdate(Cancel As Integer)
If IsNull(Forms![Drawing Management Frm]![Drawing History Frm
sous-formulaire]![Drawing Status Tbl subform].Form![Lead Date]) Then
MsgBox "You cannot enter a DMU Signature until the Lead Date is entered"
Me.DMU_Signature = Null
End If
End Sub

the problem is that is still creates an entry in the subform (a blank
entry but an entry none the less). How can I simply stop a entry from being
created altogether if the [Lead Date] field is empty/null?
 
L

Lynn Trapp

Daniel,
I'm glad it worked. Setting the Cancel parameter to True is what actually
prevents the update from happening. The Undo method sets everything back to
where it was.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Daniel said:
Lynn,

Fisrt off, I wanted to thank you ... it works perfectly!!!

Secondly, I was hoping you could briefly explain it to me. Why do I need
the cancel if I use the undo. You you enlighten me just a little bit.
Thank you once again!

Daniel
*******************************

Lynn Trapp said:
Add the following instead of the Me.DMU_Signature = Null:

Cancel = True
Me.Undo

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Daniel said:
I'm trying to use a before update event to stop the user from entering
certain information before a specific field is filled. I came up with the
following code:
Private Sub DMU_Signature_BeforeUpdate(Cancel As Integer)
If IsNull(Forms![Drawing Management Frm]![Drawing History Frm
sous-formulaire]![Drawing Status Tbl subform].Form![Lead Date]) Then
MsgBox "You cannot enter a DMU Signature until the Lead Date is entered"
Me.DMU_Signature = Null
End If
End Sub

the problem is that is still creates an entry in the subform (a blank
entry but an entry none the less). How can I simply stop a entry from being
created altogether if the [Lead Date] field is empty/null?
Thank you

Daniel
 
Top