Adding timestamp code to form with a subform.

  • Thread starter Thread starter LauraB
  • Start date Start date
L

LauraB

I'm updating a Access-2000 format database that was created ages ago to have
timestamp fields for when records are modified via the forms.

I have created the fields for four different tables. As well I have
successfully added a macro ("LastModified") to three forms via either 1)
listing the macro on the BeforeUpdate event, or 2) adding the code
'DoCmd.RunMacro "LastModified"' to the EventProcedure for the BeforeUpdate
event.

My question is... for the remaining form "Purchases" I also have a subform
"PurchaseDetails". I tried adding the code to the BeforeUpdate event, but
the code doesn't run successfully. The macro fails with error number 2950,
when tabbing to the subform. Where is the right place to put this code?
Ideally, I would like the timestamp to be associated with the Purchases table
and not the PurchaseDetails table. Although now that I'm thinking about it I
might need to add it to both tables.

Any suggestions appreciated.
 
Try this:

Public Sub UpdateTimeStamp(frm As Form)

With frm.RecordsetClone
.Bookmark = frm.Bookmark
.Edit
!TimeStamp = Now
.Update
End With

End Sub
-----------------
It works fine if called in the AfterUpdate event like this:

Private Sub Form_AfterUpdate()

UpdateTimeStamp Me

End Sub
 
Back
Top