Results 1 to 5 of 5
  1. #1
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291

    Copy a table from another database into current database

    How do I copy a table from another database into my current database?


    I tried this but it deletes my data in rstWin even though I made a clone, I guess the clone function doesnt make a copy of the recordset.

    Code:
                Dim dbWin As DAO.Database
                Dim rstWin As DAO.Recordset
                Dim rstClone As DAO.Recordset
    
                
                Set dbWin = OpenDatabase(strInputFileName)
                Set rstWin = dbWin.OpenRecordset("S_T")
                Set rstClone = rstWin.Clone
                
                rstWin.Close
                Set rstWin = Nothing
    
                
                'current database
                Dim cdb As DAO.Database
                Dim crst As DAO.Recordset
    
                Set cdb = CurrentDb()
                Set crst = cdb.OpenRecordset("Pipes")
    
                rstClone.MoveFirst
                
                If crst.RecordCount > 0 Then
                    Do While Not rstClone.EOF
                        crst.MoveFirst
                        Do While Not crst.EOF
                            If crst![SegID] = rstClone!S_LocDetails Then
                                crst.Edit
                                
                                If IsNull(rstClone!S_Street) = False Then
                                    crst!Street = rstClone!S_Street
                                End If
                                
                                rstClone.Edit
                                rstClone.Delete
        
                                crst.Update
                            End If
                            crst.MoveNext
                        Loop
                        rstClone.MoveNext
                    Loop
                End If
                
                rstClone.MoveFirst
    any help is appreciated thanks

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    well if you need to copy a table from a database to the current database you can try TransferDatabase Method:

    DoCmd.TransferDatabase acImport, "Microsoft Access", "c:\test.mdb", acTable, "Table1", "MyTable", False

    I have used this to import Table1 from a Database test.mdb in my C:\ drive and save the same in my Current Database as MyTable

  3. #3
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    Ok, it copied over the table I wanted correctly but it also created a table, I have attached a picture of it. What does it mean?

  4. #4
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I think this link will adequately explain the problem:
    Please mark the thread solved as I believe you can now able to to do what u wanted.

    http://office.microsoft.com/en-ca/ac...005257523.aspx

  5. #5
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    Ok, now I understand a little more about Name AutoCorrect, but why would it want to autocorrect this table name? There is no relationship to it and I told it what the new name should be.

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

Similar Threads

  1. Export table using third Database
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 07-27-2010, 01:04 PM
  2. Copy one table to another database
    By ashthebear in forum Access
    Replies: 2
    Last Post: 06-15-2010, 08:46 AM
  3. Replies: 3
    Last Post: 12-08-2009, 01:02 AM
  4. Multiple Table Database
    By johngreen1986 in forum Forms
    Replies: 0
    Last Post: 12-29-2008, 09:31 AM
  5. Making a backup copy of table or database
    By wasim_sono in forum Access
    Replies: 0
    Last Post: 03-09-2006, 05:44 AM

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