Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Recording or Not Recording Users Who Make Changes (Access 2000)

    I have two fields: DateModified and WhoModified, which record the date a record was last modified and who modified it. I am currently using the following code:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If MsgBox("Do you want to save changes?", vbYesNo + vbQuestion) = vbNo Then Me.Undo

    End If
    Me.DateModified = Date
    Me.WhoModified = CurrentUser()
    End Sub

    This code is supposed to ask the user if he wants to make changes. If the answer is NO it undoes all the changes and the record reverts to the original status. If the answer is YES then it saves the record and updates the DateModified and WhoModified fields.

    The problem is that even if you click NO to discard your changes, it still updates the DateModified and WhoModified fields. How can I prevent that from happening. I only want to record who made the changes if the changes are actually being kept.

    Thanks,

    JoeK

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Recording or Not Recording Users Who Make Changes (Access 2000)

    Use an Else clause:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If MsgBox("Do you want to save changes?", vbYesNo + vbQuestion) = vbNo Then
    Me.Undo
    Else
    Me.DateModified = Date
    Me.WhoModified = CurrentUser()
    End If
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Recording or Not Recording Users Who Make Chan

    Thanks, Hans.

Posting Permissions

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