Date Update

  • Thread starter Thread starter molly12
  • Start date Start date
M

molly12

Guest
I need a field to show the date that data has initially been added via a form and then I need the date to alter only when any data has been changed for that record. Ta Molly
 
Add two date fields to the table: CreatedDate and ModifiedDate.
On the form where data is added, add text boxes corresponding to these fields. It's your option whether you leave them Visible or not (see the Visible property), but i you leave them Visible you should set their Locked property to Yes so the user can't change them. Then you can use the Form's BeforeUpdate event to set these values. The code would liik something like

If IsNull(Me.CreatedDate) then Me.CreatedDate = Date()
Me.ModifiedDate = Date()

Jim
 
Am new to this. Despite some exploration couldn't get it to work.

Can you give me the exact code and/or suggest a beginners site?

Thanks
 
Don't forget to end the If statement.

Also, whenever I try to use Date() in VBA, it takes off the () when I save the code. Why is that?
 
Thank you. It worked perfectly when I paid greater attention to detail.

Molly
 

Users who are viewing this thread

Back
Top Bottom