1. Open the form in design view.
2. Set the Before Update property of the Form (not the property of a
control) to:
[Event Procedure]
3. Click the Build button (...) beside this property.
Access opens the Code window.
4. Between the "Private Sub..." and "End Sub" lines, enter:
If Not Me.NewRecord Then
If MsgBox("Save changes?", vbOkCancel + vbQuestion, _
"Confirm") = vbOk Then
Me.[UpdatedOn] = Now()
Me.[UpdatedBy] = fOSUserName()
Else
Cancel = True
Me.Undo
End If
End If
This assumes:
- You already added these fields to your table:
UpdatedOn Date/Time 'to record the last update time.
UpdatedBy Text 'to record the user
- You downloade the fOSUserName() function from this link:
http://www.mvps.org/access/api/api0008.htm
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
S Patel said:
I am looking for a code for a form that prompts me if the exixting record
is
changed and if i wamt to keep the change or delete the change. And also if
i
accept the change it puts the current date and time in updated fied am the
log in persons name who has made that change.