Before_Update Event problems

jeo

Registered User.
Local time
Today, 00:31
Joined
Dec 26, 2002
Messages
299
I have a form with some Note fields on it.
I needed to track changes every time any of the note fields changed.
I got that part to work and I put it in the Before_Update even as I'm using Note1.Oldvalue as well as Note1.Value for my changes.
The problem that I'm having with this code is that when I come back to this form and want to change Note1, it says that Access has encountered an error while saving the record and can't save.
When I take the Before_Update code out I can make my Note1 changes without any problems.
Here is what I have for my Before_Update event to keep track of changes:

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tblProjectNoteChanges", dbOpenDynaset)
With rs
.AddNew
If IsNull(Note1.OldValue) Then
![MajorIssuesOld] = "Previously no note"
![MajorIssuesNew] = Me.Note1.Value
Else
![MajorIssuesOld] = Me.Note1.OldValue
![MajorIssuesNew] = Me.Note1.Value
End If

If IsNull(Note2.OldValue) Then
![GeneralInfoOld] = "Previously no note"
![GeneralInfoNew] = Me.Note2.Value
Else
![GeneralInfoOld] = Me.Note2.OldValue
![GeneralInfoNew] = Me.Note2.Value
End If
![Changed] = Now()
.Update
End With
Set rs = Nothing

Any ideas? Is it the code, or is this placed in the wrong event? Any ideas would be greatly appreciated.
Thanks.
 
Can the "OldValue" ever be Null?

Search the forum for the keyword "Audit Trail" and my user name for a working sample on how to track changes to a record.
 
I tried searching and the only thing I found was something that keeps track of changes in a Memo or a Text Box. What I wanted is an actual table to keep track of changes. Also, I used the .oldvalue to set a default "No Previous Note".
 
I used one of the database from this forum to keep track of changes(its attached).
I'm wondering if there is a way at all to display on a different form, only changes that happened within the last two weeks.
Is there a way to somehow code for the changed data to fall within these 2 weeks?
Thanks.
 

Attachments

Users who are viewing this thread

Back
Top Bottom