Adding timestamp code to form with a subform.

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.
 
A

Arvin Meyer [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top