Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    May 2003
    Location
    Whittier, California
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Alter Table SQL Statement (2000)

    I've successfully added number & text fields to tables using the SQL ALTER TABLE statement, but cannot create a yes/no field. I've tried ALTER TABLE tmakImport ADD Final BOOLEAN; and ALTER TABLE tmakImport ADD Final YES/NO; but get a "Syntax error in field definition" error.

    What is the proper term to use?

    Kevin

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Alter Table SQL Statement (2000)

    Try BIT or YESNO (without a slash) as field type instead of BOOLEAN.

  3. #3
    Lounger
    Join Date
    May 2003
    Location
    Whittier, California
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Alter Table SQL Statement (2000)

    Well, either one does indeed create a Yes/No field, but how come when I open the table I see all zeroes instead of checkboxes?

    Kevin

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Alter Table SQL Statement (2000)

    If you create a field interactively, through the interface, Access sets the display control property for a Yes/No field to check box. SQL, however, knows nothing about the Access interface, so the display control is the default: text.

    The only way I know of to set the display control property to check box is through DAO, but perhaps others know how to to it using ADOX, for example. I think it is impossible to do it in SQL. Here is the DAO code to set the display control property:

    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Dim prp As DAO.Property

    Set dbs = CurrentDb
    Set tdf = dbs.TableDefs![tmakImport]
    Set fld = tdf.Fields![Final]
    Set prp = fld.CreateProperty("DisplayControl", dbInteger, acCheckBox)
    fld.Properties.Append prp

    Set prp = Nothing
    Set fld = Nothing
    Set tdf = Nothing
    Set dbs = Nothing

Posting Permissions

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