update or cancel update without add new or edit

janeyg

Registered User.
Local time
Today, 00:53
Joined
May 11, 2012
Messages
90
Hi

Wonder if anyone can offer any advice on this one? I get an error "update or cancel update without add new or edit" which seems to point to this code. I really can't see why, can anyone see what I am missing? I am using MS Access 2010.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Store when record was last modified and by who.
'Initially stores when the record was entered.
If Me.NewRecord = True Then Exit Sub 'Exit if new record
Me.DateLastModified.Value = Now()
Me.LastModifiedBy.Value = getUser()
End Sub

Many thanks in advance.
Janeyg
 
Last edited:
Try:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Store when record was last modified and by who.
'Initially stores when the record was entered.
If Me.NewRecord = True Then 
  Cancel = True
  Exit Sub 'Exit if new record

Else
  Me.DateLastModified.Value = Now()
  Me.LastModifiedBy.Value = getUser()
End Sub
 
Many thanks, I will give that a go!
 

Users who are viewing this thread

Back
Top Bottom