Results 1 to 4 of 4

Thread: Transfer data between two databases

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    15

    Unhappy

    here's my problem :

    I need to replace all the records of all the tables
    in my database called 'transport.mdb' by all the records
    of all the tables of my other database called '2000-04-13.mdb'. Sound simple? Not for me.

    I'm doing this in VB6 with Access databases. All I've been able to do is to delete all the records of the tables in
    'transport.mdb' and now I don't know how to 'copy' the
    content of '2000-04-13.mdb' into 'transport.mdb'.

    What would you suggest me to do?

    An example would be very appreciated...
    I'm not like them
    but I can pretend

  2. #2
    Hyperactive Member
    Join Date
    Feb 2000
    Posts
    284
    Well before deleting them all I would create a recordset of all the records, then open a connection to the other database and insert them into the appropriate table. Never had to do it though so I dont have an example to hand.

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    If the structures of both mdb's are the same, the problem is not really a database issue, but a file copying issue. You could use:
    Code:
    FileCopy "C:\MyDir\2000-04-13.mdb", "C:\MyDir\transport.mdb"
    To copy the contents of an individual table from one mdb to another, assuming the structure of both tables is identical, you could use:
    Code:
    Dim db1 As Database
    Dim db2 As Database
    Dim strSQL As String
    Set db1 = OpenDatabase("C:\MyDir\2000-04-13.mdb")
    Set db2 = OpenDatabase("C:\MyDir\transport.mdb")
    db2.Execute "DELETE * FROM MyTable", dbFailOnError
    strSQL = "INSERT INTO MyTable IN 'C:\MyDir\transport.mdb' " _
           & "SELECT * FROM MyTable"
    db1.Execute strSQL, dbFailOnError
    [Edited by BruceG on 10-06-2000 at 07:47 AM]
    "It's cold gin time again ..."

    Check out my website here.

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    15

    Thumbs up Thank you!

    Thanks BruceG for your help

    Even if the structure of both table are identical,
    the FileCopy function doesn't works for me because
    the file is already open but the example you wrote after
    that worked just fine.

    Thank you again
    I'm not like them
    but I can pretend

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