Results 1 to 5 of 5

Thread: Appending a field to more then one table

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Hello The_Inspector,

    Please show your source whith the error.

    Michelle.

  2. #2
    Junior Member
    Join Date
    Aug 1999
    Location
    Behinf you
    Posts
    24

    Post

    Private Function CreateDB()
    Const DB_LANG_GENERAL = ";LANGID=0x0809;CP=1252;COUNTRY=0"
    Dim DB As Database
    Dim tdData As New TableDef
    Dim tdGrades As New TableDef
    Dim fFirstName As New Field
    Dim fLastName As New Field
    Dim fOld As New Field

    tdData.Name = "Data"
    tdGrades.Name = "Grades"
    fFirstName.Name = "FirstName"
    fFirstName.Type = 10
    fFirstName.Size = 15
    fFirstName.Required = True
    fLastName.Name = "LastName"
    fLastName.Type = 10
    fLastName.Size = 25
    fLastName.Required = True
    fOld.Name = "Old"
    fOld.Type = 1
    fOld.Required = True

    tdData.Fields.Append fOld
    tdData.Fields.Append fLastName
    tdData.Fields.Append fFirstName
    tdGrades.Fields.Append fFirstName <-- Here I get the error
    tdGrades.Fields.Append fLastName
    .
    .
    .

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Hello The_Inspector,

    I studied your source. At the moment you are appending a field definition to a table, it is linked to that table and it is not possible to use the same field definition a second time.

    for example:

    Set DB = CreateDatabase(DBset, dbLangGeneral)

    tdData.Fields.Append fOld
    tdData.Fields.Append fLastName
    tdData.Fields.Append fFirstName
    DB.TableDefs.Append tdData
    DB.Close 'X)

    Set DB = OpenDatabase(DBset)
    tdGrades.Fields.Append fFirstName 'X)
    tdGrades.Fields.Append fLastName
    DB.TableDefs.Append tdData

    X) After closing the DB, the information in field definition fFirstName & fLastName & tdData is lost.

    Thanks to uncle Bill G.

    Sorry that I can't help you, but you have to create your field definitions twice! (maybe not in VB6)

    Nice regards,

    Michelle.


  4. #4
    Junior Member
    Join Date
    Aug 1999
    Location
    Behinf you
    Posts
    24
    Welp, if there isn't another way then I guess the best thing to do is either make a loop or a function that resets the fields' information...

    10x for your help

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Hello The_Inspector,


    Maybe this helps:

    DB.Execute ("select * into Newtable from ExistingTable")

    This SQL command makes a copy of a table (with contents) to another table.


    Nice regards,

    Michelle.

Posting Permissions

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



Click Here to Expand Forum to Full Width