Importing to existing table

Pipo

Registered User.
Local time
Today, 10:10
Joined
Jan 13, 2016
Messages
23
Good day everyone.

I need help on this matter.

Im using this code to import a Table from a different Access database.

Code:
DoCmd.SetWarnings False
    DoCmd.TransferDatabase acImport, "Microsoft Access", selectFile, acTable, "Tbl_InvDV_28-01-2016", "Temp_DV", False
DoCmd.SetWarnings True

Im sorry if this may be confusing. What Im trying to accomplish is to Import the Data From a different Access Databse (Tbl_InvDV_28-01-2016) to an existing table (Temp_DV), the code works but instead of inserting the data to the existing table it creates a new table (Temp_DV1, 2...).
 
you may try this code:

Code:
Dim db As Dao.Database
Set db = CurrentDb

db.Execute "INSERT INTO [COLOR=Blue]localTableName[/COLOR] " & _
"SELECT * FROM [COLOR=Blue]remoteTableName[/COLOR] " & _
"IN '[COLOR=Blue]C:\Path\RemoteDatabaseName.accdb[/COLOR]'"

Set db = Nothing
replace the blue-colored text with the proper table name and database path and name.
 
Thank you for the reply.

I got a Run-time error '3134' Syntax error in INSERT INTO statement

Code:
Dim db As Dao.Database
Set db = CurrentDb

db.Execute "INSERT INTO Temp_DV " & _
"SELECT FROM Tbl_InvDV " & _
"IN C:\Users\DSWD\Desktop\Inventory of DV_28-01-2016"

Set db = Nothing

Is it possible to use File dialog to select where the file is located?
 
Error in INSERT arises through not transcribing accurately

"SELECT * FROM remoteTableName " & _
"IN 'C:\Users\DSWD\Desktop\Inventory of DV_28-01-2016'"

Yes, you can use File object to select the file from which to import.
 

Users who are viewing this thread

Back
Top Bottom