Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to cancel BeforeUpdate event if certain field (2000)

    I have an BeforeUpdate Even procedure on a form. This updates a date modified and user modified field for the record updated. I would like to cancel the BeforeUpdate event if the field that is updated is a certain checkbox. How can I do that?

    Here the code

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    'I'm sure I need to use and if then statement but not sure what property to evaluate.

    If me.checkbox1 = ? then
    cancel = true
    else
    'update date modified field
    Me.DateModified = Now()
    'update Usermodified field with network user name
    Me!UserModified = acbNetworkUserName()
    end if

    End Sub

    What do you think?
    Sarah

  2. #2
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to cancel BeforeUpdate event if certain field (2000)

    Sarah...

    I don't have time to test it myself but I believe you can test the OldValue property of the check box.... <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16>

    Try... If Me.Checkbox1 <> Me.Checkbox1.OldValue Then...

    HTH <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to cancel BeforeUpdate event if certain field (2000)

    Yes! That worked!

    Thanks Trudi!

    Sarah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •