Hi Kristi,
First, I question why you are storing an Age value. This sounds like something that should be
calculated on-the-fly, based on a birth date and the computer's system date (which, of course,
must be accurate to calculate the correct ages). Storing the results of any calculation, such as
age, violates third normal form in database design. It requires that someone, like you,
periodically update the data in an attempt to prevent inaccurate data. That being said, you can
update your UpdatedDate field by using the Before_Update event procedure of textbox that your age
is displayed in. For the purposes of this example, the age field is displayed in the textbox
named txtAge and the UpdatedDate field is displayed in a textbox named txtUpdatedDate. It
underlying datatype Date/Time. Use the following VBA procedure, in the form's code module, to
accomplish your update:
Option Compare Database
Option Explicit
Private Sub txtAge_BeforeUpdate(Cancel As Integer)
Me.txtUpdatedDate.Value = Date
End Sub
If you want the date and time of day stored, then use the Now function in place of the Date
function above. Other suggestions include setting the locked property for txtUpdatedDate to Yes,
and changing the backcolor property to something different from the default white. A light grey
works nice (12632256). The change in backcolor provides your users with a visual clue that the
data cannot be edited. Finally, I would remove the tab stop from the txtUpdatedDate textbox,
which is found on the Other tab of the properties view.
Tom
_____________________________________
Hi,
I have a field called UpdatedDate that I would like to calculate when a change is made to my Age
field. In other words, if I change the number in my Age field, I want the UpdatedDate field to
display today's date. How would I go about making that work?
Thank you!