Results 1 to 3 of 3

Thread: MS-Access Set Default Value of Column Using VBA

  1. #1
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14

    MS-Access Set Default Value of Column Using VBA

    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:

    Code:
    ALTER TABLE [table1]
    ALTER COLUMN [column1] number SET DEFAULT 0
    Code:
    ALTER TABLE [table1]
    ALTER COLUMN [column1] number DEFAULT 0
    Code:
    ALTER TABLE [table1]
    MODIFY COLUMN [column1] number DEFAULT 0
    but nothing is working.


    Please help me on this.


    Thanks in advance.

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi,


    You could write this VBA in Access

    Code:
       Set db = CurrentDb
       
       db.TableDefs("table1").Fields("column1").Properties("DefaultValue") = "0"
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14
    Thanks it's working :Cheers:

Similar Threads

  1. Replies: 5
    Last Post: 04-18-2013, 02:30 AM
  2. VBA Validation List set
    By xander1981 in forum Excel Help
    Replies: 3
    Last Post: 02-15-2013, 04:07 PM
  3. default flag on vba
    By tushar.tarafdar in forum Excel Help
    Replies: 1
    Last Post: 10-09-2012, 07:41 PM
  4. Default Cell Format Changed to Date
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 05-07-2012, 10:14 PM
  5. Set Chart size using VBA
    By LalitPandey87 in forum Excel Help
    Replies: 3
    Last Post: 11-08-2011, 08:54 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •