简体   繁体   中英

Importing only several fields from an ODBC database table into an access table

This works for importing an entire table from the ODBC database into Access:

DoCmd.TransferDatabase acImport, "ODBC Database", "ODBC;DSN=SuperBase", acTable, "BDONAMES", "BDONAMES", False

But there is a table in the ODBC database with 517 fields and I only want to import, let's say, 5 or 6 columns/fields. What is the best way to do this using VBA? I googled for a couple days and read 10 or 15 threads on stackoverflow but I haven't seen this specific question answered. Thanks in advance

Try something on the lines of:

sSQL="SELECT This,That,TheOther,Columns INTO BDONames " _
   & "FROM [ODBC;DSN=SuperBase].BDONAMES"
CurrentDB.Execute sSQL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM