I need help with Adding a Field

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
 
A

Allen Browne

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 ...
 
D

Dave

Thanks the

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

worked like a champ :)

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top