Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When form changes, insert default today as date

Status
Not open for further replies.

surfbum3000

Technical User
Aug 22, 2003
156
US
I have read access help and Tek Tips attempting to find a solution. I have a table named tblMasterList with a date field, format Short Date. None of the existing records have the date field completed. I also have a form titled frmMasterList with the date field. What I want to do is have the date field filled in automatically with today's date as data is changed on the form. The default value in the table is only for new records. I want to add today's date to existing records.

I have a text box on the form with the Control Source = Date. I have tried the following but nothing has worked.

Under the Data Tab: Default Value = Date() [I also tried Now)

Under the Event Tab: After Update = Date()
On Dirty = Date()
On Got Focus = Date()
Form properties Default Value = Date()

Also, I created a Macro with Set Value using the Expression [Forms]![frmMasterList]![Date]=Date()

Tried creating a query with criteria Date(), include that in a Macro, run Macro After Update, On Dirty, On Got Focus, etc.

I know this should be simple.
 
Use the On Dirty property of the Form.


Private Sub Form_Dirty(Cancel As Integer)
Me!Your field name here = Date
End Sub
 
I also noticed that you are using [Date] as your field name. Date is a reserved word in Access. Change the field [Date] to another name like [Update].
 
Thank you very much for your help. No wonder it wasn't working! I changed the field name in the table from Date to DateUpdated. I then inserted this code in the expression builder On Dirty. Sometimes it's the little things.

Private Sub Form_Dirty(Cancel As Integer)
Me!DateUpdated = Date
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top