Use VBA to Autopopulate a date field

  • Thread starter Thread starter Clarkyboy420
  • Start date Start date
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
 
Your first code is correct, but it should be on the BeforeUpdate event, not
the AfterUpdate event.
 
Back
Top