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

Add column with default value 1

Status
Not open for further replies.

Niebotel

Programmer
Jan 1, 2007
169
NL
I try to add new colums to a table.
First line works fine
Second line works fine also
Third line gives a syntaxis error; I want to set also the default value in the new field (What is wrong)

1. db.Execute "ALTER TABLE Facturen ADD COLUMN Credittekst Text 25"

2. db.Execute "ALTER TABLE Facturen ADD COLUMN CreditBedrag Currency"

3. db.Execute "ALTER TABLE Facturen ADD COLUMN DebitBedrag Currency DEFAULT 0"

Thanks for your help on forehand

Willem
 
While the Jet engine, starting with the 4.0 version, allows such DDL, it has to be performed through the Jet OLE DB provider and ADO. Say

[tt]currentproject.connection.execute _
"ALTER TABLE Facturen ADD COLUMN DebitBedrag Currency DEFAULT 0",, _
adcmdtext + adexecutenorecords[/tt]

For more info, check out for instance and the articles linked from there.

Roy-Vidar
 
How about...


Code:
db.Execute "ALTER TABLE Facturen ADD COLUMN DebitBedrag Currency"
db.TableDefs("Facturen").Fields("DebitBedrag").Properties("DefaultValue") = 0


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top