Microsoft KB Archive/96103

= ACC: Macro to Enter Date When a Record Was Last Modified =

Article ID: 96103

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q96103



Novice: Requires knowledge of the user interface on single-user computers.



SUMMARY
This article shows you how to write a macro that will place the current date into a LastModified field in a table each time that a record is modified. You can use this method when you are editing records on a form.



MORE INFORMATION
When you use a form to edit records, you can date stamp the record by attaching a macro to the BeforeUpdate property of the form. This example uses the Customers table in the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0).

  Add the following field to the Customers table:

     Table: Customers Field Name: DateModified Data Type: Date/Time   Create the following macro called LastModified:

     Macro Name            Action --     LastModified          SetValue

LastModified Actions Item: [DateModified] Expression: Date

NOTE: There is no equal sign (=) in front of the Date function. If you put an equal sign in front of the Date function, the macro will always put the date 12/30/99 into the [DateModified] control even though the macro step window shows the correct date in the argument section.   Create a form called Modify Customers based on the Customers table. Add a few of the fields to the form as follows:

     Form Name: Modify Customers ---     ControlSource: DateModified ControlSource: CustomerID ControlSource: CompanyName ControlSource: Address

NOTE: In versions 1.x and 2.0, there is a space in the Customer ID and Company Name field names.  Enter the macro name, LastModified, into the BeforeUpdate property of the Modify Customers form. Switch the form to Form view. Note that any time you modify the record, the current date is placed in the DateModified control.</ol>

Keywords: kbhowto kbusage KB96103

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.