PDA

View Full Version : MS-Access Set Default Value of Column Using VBA



LalitPandey87
03-30-2012, 07:36 AM
Hi All,

Is it possible to modify an existing column and set its default property with a default value in MS Access using ALTER table query.

I have tried this:



ALTER TABLE [table1]
ALTER COLUMN [column1] number SET DEFAULT 0




ALTER TABLE [table1]
ALTER COLUMN [column1] number DEFAULT 0




ALTER TABLE [table1]
MODIFY COLUMN [column1] number DEFAULT 0


but nothing is working.


Please help me on this.


Thanks in advance.

Admin
03-30-2012, 08:03 AM
Hi,


You could write this VBA in Access


Set db = CurrentDb

db.TableDefs("table1").Fields("column1").Properties("DefaultValue") = "0"

LalitPandey87
04-08-2012, 09:40 AM
Thanks it's working :Cheers: