Results 1 to 4 of 4

Thread: defaultvalue

  1. #1
    Join Date
    Sep 2001
    Location
    Vienna
    Posts
    400

    Unanswered: defaultvalue

    I'm creating tabledefs with the follwing statement

    And I want to set the defaultvalue of flag to true
    I cannot find any ghint in the docs
    I'm sure one can use defaultvalue here but how
    The field "flag" should have the default entry true!!!


    Set td = db.createtabledef(rs![relname])
    With td
    Do Until rsatt.EOF
    .Fields.Append .CreateField(rsatt![attname], dbText)
    rsatt.MoveNext
    zaehler = zaehler + 1
    Loop
    .Fields.Append .CreateField("flag", dbBoolean)
    End With
    db.TableDefs.Append td


    Any suggestions?
    http://www.postgresql.org
    --Postgresql is the only kind of thing--

  2. #2
    Join Date
    Nov 2002
    Location
    San Francisco
    Posts
    251

    Thumbs up Re: defaultvalue

    yes, forget TableDefs! It's DAO and DAO is DEAD! You can use AdoX or pure SQL

    Sub CreateTable()
    'Don't forget to ADD Reference to ADOX



    Dim tbl As New Table
    Dim cat As New ADOX.Catalog
    Set objKey = New ADOX.Key

    cat.ActiveConnection = CurrentProject.Connection

    tbl.Name = "MyTable"
    tbl.Columns.Append "ID", adInteger
    tbl.Columns.Append "Column2", adInteger
    tbl.Columns.Append "Column3", adVarWChar, 50

    objKey.Name = "PrimaryKey"
    objKey.Type = adKeyPrimary
    objKey.Columns.Append "ID"
    tbl.Keys.Append objKey

    cat.Tables.Append tbl

    tbl.Columns("Column2").Properties("Default").Value = 10
    ' you can use Properties and create Autonumber, add description and validation rule ....

    End Sub



    jiri

  3. #3
    Join Date
    Sep 2001
    Location
    Vienna
    Posts
    400

    ADOX

    thanks a lot
    this is a piece of code that i really like

    DAO is now dead for me
    http://www.postgresql.org
    --Postgresql is the only kind of thing--

  4. #4
    Join Date
    Nov 2002
    Location
    San Francisco
    Posts
    251

    Re: defaultvalue

    use DAO only where ADO cannot be used. ADO cannot work with queries (ADO is more ANSI oriented and knows VIEWS and STORED PROCEDURES only), there also some special stuff like properties of currentdb ....

    ADO is also faster than DAO, so

    this (combination of ADO and DAO)
    CurrentProject.Connection.Execute CurrentDb.QueryDefs("sample").SQL

    is faster than this (pure DAO)
    CurrentDB.Execute CurrentDb.QueryDefs("sample").SQL



    jiri

Posting Permissions

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