Use VBA to Autopopulate a date field

C

Clarkyboy420

Hi All,

I have a form which contains a field called IncidentAmendDate. I would like
that field to automatically be populated with the current date whenever a
change is made to the record.

I made a few attempts to write this in VBA myself, but experienced problems;

Private Sub Form_AfterUpdate
Me.IncidentAmendDate = Date
End Sub

Whilst the above procedure gets the system date and populates the field on
the form, I then cannot move from the record or save the information. I tried
something similar to populate the underlying table instead, but had a problem;

Private Sub Form_AfterUpdate
tblIncident.IncidentAmendDate = Date
End Sub

This went to debug and told me an object was missing...

Am I being incredibly thick? Is there a better way of doing this or is there
something silly causing the lock?

Am using Access 2007.

Many Thanks in Advance,

Chris Clark
 
D

Daryl S

Your first code is correct, but it should be on the BeforeUpdate event, not
the AfterUpdate event.
 

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