Stop Record from being inserted

D

Dave

I have 3 controls on a form in an ADP. If the 2 controls equal a
certain combination and the 3rd control is null, How can I stop the
record from being inserted?
 
T

Tom van Stiphout

On Fri, 17 Jul 2009 17:34:36 -0700 (PDT), Dave

This is validation code that belongs in the Form_BeforeUpdate. If the
condition occurs, set Cancel to True and the insert will not happen.

-Tom.
Microsoft Access MVP
 
C

CompGeek78

I have 3 controls on a form in an ADP.  If the 2 controls equal a
certain combination and the 3rd control is null, How can I stop the
record from being inserted?

In the BeforeUpdate event of the form use something along these lines
(untested air code)

If control1 = "value" and control2 = "value" and isnull(control3)
then
docmd.cancelevent
msgbox "Whatever error message you wish to use."
end if

Keven Denen
 
D

Dave

Perfect...Thanks guys! (B)(B)








In the BeforeUpdate event of the form use something along these lines
(untested air code)

    If control1 = "value" and control2 = "value" and isnull(control3)
then
        docmd.cancelevent
        msgbox "Whatever error message you wish to use."
    end if

Keven Denen
 
Top