CRAETE TABLE - DEAFUALT values for the fields

D

Dejan

I am using Jet CREATE TABLE statement to create an Access
table. In Acccess 2002 Help I do not see option for
defining DEFAULT values for the fields.

Is it possible to define DEFAULT values for table fields
by using Data Definitio Language?

Thank you!
 
A

Allen Browne

You can set a literal default value, but you may need to execute the DDL
statement under ADO to get it to work, and you may not be able to assign
functions such as "=Date()" to the default value.

Example:
Dim cmd As New ADODB.Command
Dim strSql As String

'Initialize
cmd.ActiveConnection = CurrentProject.AccessConnection

'Create the Contractor table.
strSql = "CREATE TABLE MyTable (HourlyPay CURRENCY DEFAULT 20 );"
cmd.CommandText = strSql
cmd.Execute
 
D

Dejan

THank you Allan. Good enough for me.

I still find the book "Essential Access 95", which you
wrote with Alison Balter, the best book to learn Access,
regardless of version. Next best is Alison's "Mastering
Access " series, and then Ken Getz, Paul Litwin et al.
ion pair with R.Jennings books.

Are you planning new edition, to cover new stuff that
came with 2000+ versions of Access? That would be great.

Thank you again

Dejan
 
A

Allen Browne

Thank you for your compliment.

Nothing in the pipeline immediately, but who knows.
 

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