PDA

Click to See Complete Forum and Search --> : Coping tables to a external tables


rayed78
Apr 6th, 2000, 12:51 AM
I have two different databases, each one has the same table. One is an active and the other is an inactive database. At day's end I want the informantion in the active one to be append it to the the inactive one, how do I do it using VB6 and DAO? I need a little of coding guidence on how to do it. Thank you. ray-ed@usa.net

Rach877
Apr 6th, 2000, 03:26 AM
What you could do is write SQL statments to do this....

in the general declarations:

Option Explicit
Private gdbActiveDatabase as Database
Private gdbInactiveDatabase as Database
Private grstActive as Recordset

Command Button to perform task:

Dim pstrSQLSELECT as String
Dim pstrSQLINSERT as string

Set gdbActiveDatabase = _
OpenDatabase("path name to active database")
Set gdbInactiveDatabase = _
OpenDatabase("path name to inactive database")

pstrSQLSELECT = "SELECT * FROM (name of active table in database)"

Set grstActive = _
FormName.gdbActive.OpenRecordset(pstrSQLSELECT)

(this will select all records in the active table you specified, then it will assign that record set to grstActive)

you'll then want to assign the recordset to variables

and write and INSERT sql statement and execute that, which should put it into the new table!

Hopefully this will help.

Rach

pardede
Apr 6th, 2000, 06:13 AM
You could use an sql statement, something like:

dbInactive.Execute "INSERT INTO tbl_inactive
SELECT * from tbl_active"

(lookup action queries in the help for the correct syntax)