Results 1 to 2 of 2
  1. #1
    homerj56 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Location
    Roswell, GA
    Posts
    8

    Copy Table Structure (only) Problem

    I am using the following VBA code to copy a db table to another db:



    DoCmd.TransferDatabase transfertype:=acExport, _
    databasetype:="Microsoft Access", _
    databasename:=FileDest, _
    ObjectType:=acTable, Source:="Entries", _
    Destination:="Entries", structureonly:=True

    My goal is to update a destination table structure with the source table structure (both have same db structure, just different records). I have added one field at the end on the table and tried to run the code expecting the new field to appear in the destination table. Instead, the field appeared but all records were deleted.

    In fact, the same thing happens with a straight copy-and-paste selecting "structure only". Again, these tables have exactly the same structure except I have added one field in the source table.

    This code works quite nicely for forms, reports, and queries, or tables where structureonly = false, but not for tables when all I want is the structure.

    What am I missing?

  2. #2
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Hi there,

    the code works for forms, reports, queries because they don't contain any data. For tables with data you copy both structure + data, so the data are there. In the current case you just overwrite the existing table with an empty structure.
    If you want to add a column to the table in another database, you can try to pass through an ALTER TABLE statement, or use ADOX to add the column to the table.

    greetings
    Noëlla

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Complex Survey: Table Structure Design and Normalization
    By kevin007 in forum Database Design
    Replies: 2
    Last Post: 07-06-2010, 09:21 AM
  2. Copy one table to another database
    By ashthebear in forum Access
    Replies: 2
    Last Post: 06-15-2010, 08:46 AM
  3. Replies: 2
    Last Post: 04-02-2010, 07:42 AM
  4. Problem - Objects Pointing to Table Copy
    By Linda in forum Access
    Replies: 1
    Last Post: 03-22-2010, 10:52 AM
  5. An import question above the table structure
    By Shag84 in forum Import/Export Data
    Replies: 2
    Last Post: 08-20-2009, 12:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums