Re: Import Records from and external database

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: John Spencer (MVP) (spencer4_at_comcast.net)
Date: 02/04/04


Date: Wed, 04 Feb 2004 18:06:45 -0500

You need to break out the value of db2. Try something like the following.

sSQL = "INSERT INTO tbl1 " & _
        "SELECT * " & _
        "FROM tbl2 IN '" & db2 & "' "

Your sSQL was creating a statement like:

INSERT INTO tbl1
SELECT * FROM tbl2 IN db2

When you wanted something more like

INSERT INTO tbl1
SELECT * FROM tbl2
IN 'C:\My Documents\myJetDb.mdb'

That is assuming db2 is a string containing
  C:\My Documents\myJetDb.mdb

DIOS wrote:
>
> Im working on a database and im trying to import data from a external
> database though VBA/DAO. ive tried to use ISERT INTO IN but cant seem
> to get the syntax down right. Say Im working in db1 and tbl1 and have
> some code to execute a SQL statement. I want to connect to an external
> database db2 and tbl2. Now the fields are similar so i want to be able
> to map what field gets what value.
>
> I tried
>
> sSQL = "INSERT INTO tbl1 " & _
> "SELECT * " & _
> "FROM tbl2 IN db2;"
>
> where db2 is the full path to the external database. I cant seem to
> get it to work and to map my fields. Any help is appreciated.
>
> AGP



Relevant Pages