Results 1 to 3 of 3
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    Setting default attribute in ALTER TABLE

    With the statement below, I need to set the default value to a zero length field at the time the field is created. How do I do that?



    strDDL = "ALTER TABLE InstProperties ADD Column InstSerPortal Text(80)"
    conBackend.Execute strDDL, dbFailOnError

    Thanks,
    Bill

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This thread already marked as solved. Is it?

    Why are you programmatically altering table? If this is a regular occurrence, sounds like data structure is not normalized. Do you then have to modify queries, forms, reports?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Hi June,
    As shown in the orginal post, strDDL = "ALTER TABLE InstProperties ADD Column InstSerPortal Text(80)", the initial value of the added column is NULL. That was causing some problems when the new variable was being referenced in code FOR THE FIRST TIME.

    The code is in the applications set installation properties that loads up the applications global set. As the application functionality is expanded over time per client requests, it sometimes is necessary for the initialization code to make additions to the backend DB as new versions are released to the field. I.e., DB's in the field need to be updated per the new versions enhancements.
    The DB's carry in their installation properties the compatibility version corresponding to the various releases of the app.

    While adding "DEFAULT '' " in fact set the default attribute of the field, it did not set the newly added field to a zero-length value. I just did it manually after the record was updated to include the new field.

    Bill

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Automaticly Setting Default Value
    By swicklund in forum Forms
    Replies: 5
    Last Post: 06-17-2013, 08:08 AM
  2. Replies: 4
    Last Post: 11-04-2012, 10:46 AM
  3. Setting default vaulue?
    By djclntn in forum Forms
    Replies: 17
    Last Post: 04-12-2012, 11:20 PM
  4. Form Field Default Setting
    By roofbid in forum Programming
    Replies: 3
    Last Post: 12-17-2010, 10:53 AM
  5. Replies: 1
    Last Post: 11-01-2010, 06:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums