'************************************** ' Name: Database Table Copy ' Description:This code will copy all fi ' elds from all tables in a database and a ' dd them to another identical database. My company has Rep submitting database reports all the time. I need to append the data from the reports database to a live database. At first I was running querys I had made in the database but our file structure changed and that was no long an option. This is about as simple as it gets but someone might find it useful. ' By: Shawn Jetton ' ' ' Inputs:Call the function like this. AddData "C:\My Documents\Test\From.mdb", "C:\My Documents\Test\To.mdb" ' ' Returns:None ' 'Assumes:None ' 'Side Effects:None that I know of. ' 'Warranty: 'Code provided by Planet Source Code(tm) ' (http://www.Planet-Source-Code.com) 'as ' is', without warranties as to performanc ' e, fitness, merchantability,and any othe ' r warranty (whether expressed or implied ' ). 'Terms of Agreement: 'By using this source code, you agree to ' the following terms... ' 1) You may use this source code in per ' sonal projects and may compile it into a ' n .exe/.dll/.ocx and distribute it in bi ' nary format freely and with no charge. ' 2) You MAY NOT redistribute this sourc ' e code (for example to a web site) witho ' ut written permission from the original ' author.Failure to do so is a violation o ' f copyright laws. ' 3) You may link to this code from anot ' her website, provided it is not wrapped ' in a frame. ' 4) The author of this code may have re ' tained certain additional copyright righ ' ts.If so, this is indicated in the autho ' r's description. '************************************** Public Sub AddData(DataFrom As String, DataTo As String) Dim dbFrom, dbTo As Database Dim rsFrom, rsTo As Recordset Set dbFrom = OpenDatabase(DataFrom) Set dbTo = OpenDatabase(DataTo) For n = 0 To dbFrom.TableDefs.Count - 1 'This search out on table in your databa ' se If dbFrom.TableDefs(n).Attributes = 0 Then Set rsFrom = dbFrom.OpenRecordset(dbFrom.TableDefs(n).Name) Set rsTo = dbTo.OpenRecordset(dbTo.TableDefs(n).Name) End If 'Loops through all fields in table and c ' opies from dbFrom to dbTo. Do Until rsFrom.EOF rsTo.AddNew For i = 1 To rsTo.Fields.Count - 1 If rsFrom.Fields(i) = "" Then GoTo hell rsTo.Fields(i) = rsFrom.Fields(i) hell: Next i 'This updates and moves to the next reco ' rd in the from database rsTo.Update rsFrom.MoveNext Loop Next n dbFrom.Close dbTo.Close End Sub