I need help with Adding a Field

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I want to add a field on a server based Access db. I am trying to use the
ALTER command and setting the Default value of the field.

ALTER TABLE TSSCalls ADD COLUMN Dte Date Date()

I want to create the Fieldname DTE as a Date field with the default
expression Date()

I can create the field, set it's data type as a date but I cannot figure out
how to set the default expression. Can anyone help?

Thanks

Dave
 
2 tricks:
1. Add the keyword DEFAULT.
2. Execute the query under ADO.

#1. Actually, I've only tried this with a CREATE TABLE, but the syntax would
be:
ALTER TABLE TSSCalls ADD COLUMN Dte Date DEFAULT Date()

#2. You can't run this query directly from the query window, since Access
uses DAO and Microsoft did not update DAO to support most of the new JET 4
features. So you would need to run the query programmatically using ADO:
CurrentProject.Connection.Execute "ALTER ...
 
Thanks the

mySQL="ALTER TABLE TSSCalls ADD COLUMN Dte Date DEFAULT Date()"

worked like a champ :-)

Dave
 
Back
Top