Need clarification on BeforeUpdate and such...

  • Thread starter Thread starter Ben Moore
  • Start date Start date
B

Ben Moore

Ok, what I need to accomplish is a sort of timestamp for an entry. I
have a jobs database, information related by ID numbers. I would like,
when we enter a new job, for there to be a field that is "timestamped"
with the current date. I think i can figure out how to do it in VBA,
except I don't know what to use for the form's method. I know there are
things like BeforeUpdate and the like, but I don't know which to use.
Any and all help is appreciated.

Thanks in advance.

cheers,
Ben Moore
 
Ben Moore said:
Ok, what I need to accomplish is a sort of timestamp for an entry. I
have a jobs database, information related by ID numbers. I would like,
when we enter a new job, for there to be a field that is "timestamped"
with the current date. I think i can figure out how to do it in VBA,
except I don't know what to use for the form's method. I know there
are things like BeforeUpdate and the like, but I don't know which to
use. Any and all help is appreciated.

Thanks in advance.

cheers,
Ben Moore

Do you want the current date, or the date and time? For the date alone,
set the field equal to the Date() function; for date and time use the
Now() function instead. Also, do you want to distinguish between a
record being created -- that is, saved for the first time -- and being
updated? If you only want to capture the moment when the record is
created, you don't need any code at all. Just set your field's Default
Value property to Date() or Now() in the design of the *table*. If you
want to timestamp each record whenever it is modified, use the
BeforeUpdate event of the form, with an event procedure along these
lines:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Me.LastUpdated = Now()

End Sub

In the above "LastUpdated" is the name I've chosen for the time-stamp
field.

I frequently have two fields for this: one for WhenCreated and one for
WhenUpdated.
 
Thanks a bunch there Dirk, setting the default value equal to Date()
worked like a charm. Much appreciated.

Thanks again.

cheers,
Ben Moore
 
Back
Top