Before update is called when only viewing a record

imperator

Archaeologist etc.
Local time
Today, 18:12
Joined
Feb 28, 2004
Messages
38
Hi All

I am trying to use the following code on a form to record when the data in a record is modified:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    On Error GoTo BeforeUpdate_Err
    
    ' Set bound controls to system date and time.
    UserModified = fOSLogin()
    DateModified = Date
    TimeModified = Time()
    
BeforeUpdate_End:
    Exit Sub
BeforeUpdate_Err:
    MsgBox Err.Description, vbCritical & vbOKOnly, _
        "Error Number " & Err.Number & " Occurred"
    Resume BeforeUpdate_End
End Sub

It is 'sort of' working except that it fills in the fields even if I only view the record on the form and change nothing. Is this normal behaviour?

Ray
 
no - you must be setting a value in code somewhere. current event probably. even if the value is unchanged, setting it in code will cause the record to "dirty"

show record selectors on the form, and it will show a pencil, indicating the record has been changed, and needs saving.
 
no - you must be setting a value in code somewhere. current event probably. even if the value is unchanged, setting it in code will cause the record to "dirty"

show record selectors on the form, and it will show a pencil, indicating the record has been changed, and needs saving.

I suspected as much. Okay, I'll try your tip.
Many Thanks.
Ray
 
Thanks Dave, solved. I had a bit of code being called by On Current all the time. Move it elsewhere.
Cheers
Ray
 

Users who are viewing this thread

Back
Top Bottom