Results 1 to 4 of 4

Thread: Create .mdb table using ADOX

  1. #1
    Join Date
    Aug 2005
    Posts
    2

    Create .mdb table using ADOX

    Hello.... I'm creating a .mdb table in VB using ADOX. All the fields are by default being set to "required" (doesn't take null values). How do I disable this so that the fields take null values. Also I'm trying to create an index for field "froid". I've ran out of ideas and would greatly appreciate some new insight. Thank alot

    Dim catDB As ADOX.Catalog
    Dim tbl As ADOX.Table

    Set catDB = New ADOX.Catalog

    catDB.ActiveConnection = connString

    Set tbl = New ADOX.Table
    With tbl
    .Name = strScrambledTable
    Set .ParentCatalog = catDB

    'create fields
    With .Columns
    .Append "froid", adVarWChar, 100
    CREATE INDEX R "froid" .Append "toid_ident", adInteger
    .Item("toid_ident").Properties("AutoIncrement") = True
    .Append "toid", adVarWChar, 50
    .Append "excchk", adInteger
    End With

    End With

    catDB.Tables.Append tbl
    Set catDB = Nothing

  2. #2
    Join Date
    Aug 2005
    Posts
    29
    The property name for required is Nullable.. i.e. set
    .item(<itmname>).properties("nullable") = true

    Note:You won't be able to touch the nullable property of autoincrement field.

    To add index tbl.Indexes.Append "idx1", "froid"
    ------------------------------------------------
    Set tbl = New ADOX.Table
    With tbl
    .Name = "NEWTABLE1"
    Set .ParentCatalog = catDB
    'create fields
    With .Columns
    .Append "froid", adVarWChar, 100
    .Append "toid_ident", adInteger
    .Item("toid_ident").Properties("AutoIncrement") = True
    .Append "toid", adVarWChar, 50
    .Append "excchk", adInteger
    'NULLABLE SYNTAX__________
    .Item("toid").Properties("Nullable") = True
    .Item("excchk").Properties("Nullable") = True
    '_________________________
    End With
    'INDEX SYNTAX____________
    .Indexes.Append "idx1", "froid"
    '________________________
    End With
    catDB.Tables.Append tbl
    Last edited by rt_roh; 08-11-2005 at 12:22 PM. Reason: Half answer

  3. #3
    Join Date
    Aug 2005
    Posts
    2
    Code works perfectly... I really appreciate it.. Thanks you very very much....

    Another question. For the autonumber field is it possible to start from a certain value like 123412345? If so how would you do it? And for the index it sets it so that "duplicates ok". How do i set it to the property "no duplicates".....Thanks
    Last edited by abcd1234; 08-11-2005 at 12:46 PM.

  4. #4
    Join Date
    Aug 2005
    Posts
    29
    I have a workaround for duplicate problem. Couldn't change the unique property properly. hope it is ok for u.
    Add unique key before creating index. Doing this first, creates non duplicate index.

    .Keys.Append "froidunique", adKeyUnique, "froid"
    .Indexes.Append "idx1", "froid"

    And don't have any idea abt initializing autoincrement field.

Posting Permissions

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