I am writing a number of scripts to update numerous Access tables. I would like to add a column to each that has a field called "date_created" that is a timestamp of when the record is created. Doing this through the table view is simple, simply set the DefaultValue = now(). However, how would I accomplish this in sql?
This is my current attempt for tables that already have the column. This example uses "tblLogs".
ALTER TABLE tblLogs ALTER COLUMN date_created DEFAULT now()
Thanks for your help!
Update - Would there be a way to do this in VBA?
Update 2 - Tested all of the answers and the following by onedaywhen is the shortest and most accurate
CurrentProject.Connection.Execute _
"ALTER TABLE tblLogs ALTER date_created DATETIME DEFAULT NOW() NOT NULL;"