Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add table description via DAO (97)

    My application creates a number of linked tables in the current database. No problem getting the linked tables defined, but I would like to add a description field to the table definition so it appears in the Access UI. The following code fails with Error Code 3219. Does anybody know the correct syntax? Thanks.

    Dim prp As DAO.Property
    Dim tdf As DAO.TableDef

    [ snip]
    Set tdf = CurrentDb.CreateTableDef(sTablename & "_AOWWeb")
    tdf.Connect = ";Database=" & txtWebBEPath
    tdf.SourceTableName = sTablename
    Set prp = tdf.CreateProperty("Description", dbText, "_AOWWeb")
    ' tdf.Properties.Append prp <==== Fails here with error code #3219
    CurrentDb.TableDefs.Append tdf
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add table description via DAO (97)

    Try appending the table to the database first, then create the property and append it to the table. You can't create a property for a table until the table is actually added to the TableDefs collection. Also, be aware that using CurrentDb that way uses a separate databae pointer each time you reference it, which is eliminated if you dim a dbs As DAO.Database and then set it to CurrentDb.
    Charlotte

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

    Re: Add table description via DAO (97)

    You need to change two things:

    1. You must declare an object of type DAO.Database and use that:

    Dim dbs As DAO.Database
    Set dbs = CurrentDb

    and replace CurrentDb by dbs in the code.

    2. You must append the TableDef to the TableDefs collection before setting the Description property.

    <img src=/w3timages/blueline.gif width=33% height=2>

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

    [snip]

    Set dbs = CurrentDb
    Set tdf = dbs.CreateTableDef(sTablename & "_AOWWeb")
    tdf.Connect = ";Database=" & txtWebBEPath
    tdf.SourceTableName = sTablename

    dbs.TableDefs.Append tdf

    Set prp = tdf.CreateProperty("Description", dbText, "_AOWWeb")
    tdf.Properties.Append prp

    [snip]

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

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add table description via DAO (97)

    Charlotte and Hans
    Thanks much. That did it!
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

Posting Permissions

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