PDA

Click to See Complete Forum and Search --> : Transfer databases in VB6


Caro
Oct 6th, 1999, 10:36 PM
I have seen documented a TransferDatabase Method within Access - is there anything I can use in VB6 to transfer tables from a database located in one place to another database? (other than via DOS commands?)

I need to be able to export and import sections of an access database using VB6.

Off2Cabo
Oct 7th, 1999, 12:17 PM
To transfer data from one table into another table in a different .mdb. Try the following:

Private Sub cmdTransfer_Click()

Dim dbOne As Database
Dim dbTwo As Database
Dim SQL As String

On Error GoTo ErrHnd
'Just in case it screws up

Set dbOne = Workspaces(0).OpenDatabase("c:\Wherever\Wherever\Main.mdb")
'Obviously, this is the first db
'just set pathway
Set dbTwo = Workspaces(0).OpenDatabase("c:\Wherever\Wherever\Other.mdb")
'duh, and the second database

SQL = "INSERT INTO Table1,Table2,Table3 IN 'c:\Wherever\Wherever\Other.mdb'SELECT Table1,Table2,Table3. *FROM Table1,Table2,Table3"

dbOne.Execute SQL, dbFailOnError

dbOne.Close

Set dbOne = Nothing

Exit Sub

ErrHnd:

MsgBox Err.Description

'Just define where the two db's are
'and what you want in them
'just be sure to include the ' '
'marks in the SQL part
'Simple as butter...........

End Sub


Hope This Helps,

--Steph

------------------


[This message has been edited by Off2Cabo (edited 10-08-1999).]

Caro
Oct 7th, 1999, 07:14 PM
Thanks - that looks great - just what i'm after