Automatic update of Date fields, Access 2003

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to add a field to my Customer Contacts table that automatically
sets to the date the record was entered plus another date field that resets
automatically to the date a record is altered. Can I do this and how?
 
The creation date is easy. Just add a field to your table, and set its
Default Value property to:
=Date()

The modification date can only be achieved if you update your data through a
form. Use the BeforeUpdate event procedure of the form to set the field's
value to Date.
 
Thanks Allen,

how do I do this:
The modification date can only be achieved if you update your data through a
form. Use the BeforeUpdate event procedure of the form to set the field's
value to Date.
 
1. Open your form in design view.
2. Open the properties box (View menu).

3. Making sure the Title of the Properties box reads "Form" so you are
looking at the properties of the form, not those of a control, choose the
Before Update property on the Events tab.

4. Set the Property to
[Event Procedure]

5. Click the Build button beside this. Access opens the code window.

6. Make it read like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[NameOfYourDateFieldHere] = Date
End Sub
 
Thanks Allen,
that worked beautifully. Great help.

Allen Browne said:
1. Open your form in design view.
2. Open the properties box (View menu).

3. Making sure the Title of the Properties box reads "Form" so you are
looking at the properties of the form, not those of a control, choose the
Before Update property on the Events tab.

4. Set the Property to
[Event Procedure]

5. Click the Build button beside this. Access opens the code window.

6. Make it read like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[NameOfYourDateFieldHere] = Date
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

HeinzD said:
Thanks Allen,

how do I do this:
 
Back
Top