Automatic update of Date fields, Access 2003

H

HeinzD

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

Allen Browne

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

HeinzD

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

Allen Browne

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
 
H

HeinzD

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:
 

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