Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Posts
    123

    Unanswered: How do I iterate through and copy all objects to another db?

    I want to iterate through every table (and maybe each form) and copy each to another database. I tried a For...Each...Net, but couldn't get past the run-time error "object required". Or better yet, how do I get rid of replication on a database. It somehow got added and I don't want it.

    Sub CopyItAll()
    Dim dbs As Database
    Dim tbl As TableDef
    Dim qry As QueryDef
    Dim mdl As Module
    Dim frm As Form

    Set dbs = CurrentDb

    For Each tbl In TableDefs
    DoCmd.CopyObject "H:\MontreSys\Montre_v20\Montre_v20_devnew.mdb ", tbl.Name, acTable, tbl.Name
    Debug.Print "Copying table " & tbl.Name & "..."
    Next

    For Each qry In QueryDefs
    DoCmd.CopyObject "H:\MontreSys\Montre_v20\Montre_v20_devnew.mdb ", qry.Name, acQuery, qry.Name
    Debug.Print "Copying query " & qry.Name & "..."
    Next

    For Each mdl In Modules
    DoCmd.CopyObject "H:\MontreSys\Montre_v20\Montre_v20_devnew.mdb ", mdl.Name, acQuery, mdl.Name
    Debug.Print "Copying module " & mdl.Name & "..."
    Next

    For Each qry In Forms
    DoCmd.CopyObject "H:\MontreSys\Montre_v20\Montre_v20_devnew.mdb ", frm.Name, acForm, frm.Name
    Debug.Print "Copying form " & frm.Name & "..."
    Next


    End Sub

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Why not simply create a blank db and then import all tables/forms into it?
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Aug 2003
    Posts
    123
    I guess the real problem is that my db somehow got replication added, so all the tables and queries now have the system fields for replication. I don't want this, and if I try to import, or copy or whatever the replication fields stay. I don't want to have to start the db over, so is there a way to copy/import without transferring the replication fields, or to simply turn off replication?

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Take a look at this link. It tackles this question and gives several links, including, I believe a Microsoft white paper on the subject.

    http://www.tek-tips.com/viewthread.cfm?qid=1173017
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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