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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating database table with DefaultValue properties

Status
Not open for further replies.

Griffyn

Programmer
Jul 11, 2002
1,077
AU
Hi all,

I'm creating an MS Access database and then adding a table. But I want one of the fields in this table to have a default value. Access allows this, but I cannot seem to programmatically set it. I'm using this code:
Code:
[b]var[/b]
  x : OLEVariant;
[b]begin[/b]
  x := CreateOleObject('ADOX.Catalog');  
  [b]try[/b]
    x.Create('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=''newdb.mdb'';Jet OLEDB:Engine Type=4;');
  [b]finally[/b]
    x := Unassigned;       
  [b]end[/b];
[b]end[/b];

And then I'm using TADOCommand to issue a CREATE TABLE SQL command to create the table. But how to set a default value? Specifically, a date field with a default value of '=Now()'.

Thanks!
 
I just answered a similar question, and presume this one can be solved in the same way. Just in case others would like to know too. See thread102-1361307
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top