Hi Endee,
Instead of using the Form_AfterUpdate event procedure, use the BeforeUpdate
event procedure. You can uncomment the two indicated lines if you only want
new records timestamped. I suspect that you want all records timestamped,
based on your initial post.
Note that the record must be saved in order for the Form_BeforeUpdate event
procedure to run. In other words, if you have the record selector displayed,
the record is dirty (not saved) if you can see the pencil symbol. This means
that you either have to navigate to a new record, and then come back to the
existing record, or add a Save Record command button to the form, or close
and re-open the form.
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo ProcError
'If Me.NewRecord = True Then
Me.DateAmended = Date
'End If
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Form_AfterUpdate..."
Resume ExitProc
End Sub
If this is not acceptable (ie. you want the DateAmended to be immediate,
even if the record is still dirty), then create a new function in the form's
module like this:
Private Function DateLastEdited()
On Error GoTo ProcError
Me.DateAmended = Date
ExitProc:
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure DateLastEdited..."
Resume ExitProc
End Function
Then, in form design view, with the properties dialog displayed, enter the
following into the AfterUpdate event procedure for all controls where the
user can change the data: =DateLastEdited()
You can use the "lasso" technique in form design view, to select several
controls at once.
Tom
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
:
Thanks, I have tried that, and it did not update the form after updates. I
have also tried doing it from the entire form point of view using this code:
Private Sub Form_AfterUpdate()
If Me.NewRecord = True Then
Me.DateAmended = Date
End If
End Sub
Yet there's no improvement. Is there another way?
_______________________________________________
:
I have an active form functioning very well. My problem is that, I want any
update in any text field in the form to trigger the 'current system date' to
be displayed in one of the fields I have labelled 'date amended'. I want to
do this with codes alone and so far, this is what i came up with:
Private Sub DateAmended_AfterUpdate()
If Form.CurrentRecord = 1 Then
Me.DateAmended = Date
End If
End Sub
I dont know what to substitute currentrecord with. Please anyone, help me.