Import fields

J

Jay

Is there an event procedure that will import a table from an access database
to another access database and only 4 fields instead of all 10 fields.
I would like to be able to select fields I need. I can do it with
a text file.
 
A

Allen Browne

You can use an Append query statement to import specified fields into your
table.

Example:

strSql = "INSERT INTO MyTable ( CusID, Company ) " & _
"SELECT Customers.CustomerID, Customers.CompanyName " & _
"FROM Customers IN 'C:\northwind.mdb';"
dbEngine(0)(0).Execute strSql, dbFailOnError
 
J

Jay

Allen said:
You can use an Append query statement to import specified fields into your
table.

Example:

strSql = "INSERT INTO MyTable ( CusID, Company ) " & _
"SELECT Customers.CustomerID, Customers.CompanyName " & _
"FROM Customers IN 'C:\northwind.mdb';"
dbEngine(0)(0).Execute strSql, dbFailOnError


I have never used the select method before. Where do I copy this example
too?
 
A

Allen Browne

You asked for an "event procedure", so I gave you the code to put into the
event procedure, assuming you would put it into something like the Click of
a command button.

Alternatively, you could put just the query statement itself into an Append
query. You do need to change the query statement so it uses your field
names, table names, and file name. The query statement part would be just:
INSERT INTO MyTable ( CusID, Company )
SELECT Customers.CustomerID, Customers.CompanyName
FROM Customers IN 'C:\northwind.mdb';

Perhaps you would like to attach the table from the other database:
File | Get External | Link
You could then create a query on that table in the other database, and then
change it to an Append query (Append on Query menu, in query design view.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top