set creat date and last update date

  • Thread starter Thread starter leungkong
  • Start date Start date
L

leungkong

i want to set a creat date and last update date in form.

creat date and last update will be add automatically when the record creat.
last update will be update everytime when saving.

how to set auto update the textbox when i save the form? Thanks.
 
The CreatDate is easy: just set its Default Value property to:
=Date()
or if you want the time as well as the date:
=Now()

For the LastUpdate field, use the BeforeUpdate event procedure of the form
to assign the value. That's the last possible moment before the changes are
saved. This kind of thing:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[LastUpdate] = Now()
End Sub
 
manys thanks.

Allen Browne said:
The CreatDate is easy: just set its Default Value property to:
=Date()
or if you want the time as well as the date:
=Now()

For the LastUpdate field, use the BeforeUpdate event procedure of the form
to assign the value. That's the last possible moment before the changes are
saved. This kind of thing:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[LastUpdate] = Now()
End Sub

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

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

leungkong said:
i want to set a creat date and last update date in form.

creat date and last update will be add automatically when the record
creat.
last update will be update everytime when saving.

how to set auto update the textbox when i save the form? Thanks.
 
Back
Top