none
DAO db.CreateTableDef works one way not another?!? RRS feed

  • Question

  • Documentation says you can:

    expression.CreateTableDef(Name, Attributes, SourceTableName, Connect)
    expression A variable that represents a Database object.

    But this works:

        Set tdf = db.CreateTableDef(strLocalLinkedTable)
        tdf.SourceTableName = strSourceTbl
        tdf.Connect = ";DATABASE=" & strSourceDBpath
        db.TableDefs.Append tdf

    And this doesn't:

        Set tdf = db.CreateTableDef(strLocalLinkedTable, , strSourceTbl, ";DATABASE=" & strSourceDBpath)
        db.TableDefs.Append tdf

    Any idea why not? Is that documented somewhere? Why does the method call accept the parameters if it ignores them?

    Tuesday, October 10, 2017 12:40 AM

Answers

  • Because the Attributes argument cannot be 0 -  after all this is a linked table. Change it to this:

     Set tdf = db.CreateTableDef(strLocalLinkedTable, dbAttachSavePWD, strSourceTbl, ";DATABASE=" & strSourceDBpath)


    -Tom. Microsoft Access MVP

    • Marked as answer by Dick Watson Tuesday, October 10, 2017 2:28 AM
    Tuesday, October 10, 2017 1:05 AM

All replies

  • Because the Attributes argument cannot be 0 -  after all this is a linked table. Change it to this:

     Set tdf = db.CreateTableDef(strLocalLinkedTable, dbAttachSavePWD, strSourceTbl, ";DATABASE=" & strSourceDBpath)


    -Tom. Microsoft Access MVP

    • Marked as answer by Dick Watson Tuesday, October 10, 2017 2:28 AM
    Tuesday, October 10, 2017 1:05 AM
  • That worked the trick. Funny that you can never set it separately and it works but if you don't supply it in the original method call it doesn't work.

    So may quirks, so little time.

    Thanks!

    Tuesday, October 10, 2017 2:29 AM