|
-
Oct 6th, 1999, 10:36 PM
#1
Thread Starter
Addicted Member
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.
-
Oct 7th, 1999, 12:17 PM
#2
New Member
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).]
-
Oct 7th, 1999, 07:14 PM
#3
Thread Starter
Addicted Member
Thanks - that looks great - just what i'm after
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|