|
|
|||||||
| Home Page |
|||||||
Importing External Access Database Tables Using Visual Basic by Nicholas BrownSometimes a Microsoft Access database user may find it desirable to automate the process of importing tables from an external Access database file into their current database. Below is a segment of code that provides an example of how to accomplish this.
‘*******CODE******* Dim root As String Dim srcDB As database Dim tdf As TableDef Dim x As Integer
Root = “C:” Set srcDB = OpenDatabase(root) For Each tdf In srcDB.TableDefs x = 0 If (tdf.Name = "CULVERT") Then DoCmd.TransferDatabase acImport, "Microsoft Access", root, acTable, "CULVERT", "CULVERT" errorCheck = 1 End If Next tdf
‘******************
After the variable declarations, the first line of code sets the variable “root” equal to “C:” which is the location of the external database holding the tables we wish to import. The next line sets our database variable equal to the external database. The next lines of code search through the external database to find the table named “CULVERT.” If this table is found, the table is imported using the DoCmd function. The “acImport” variable simply tells the function that we wish to import information from the database. “Microsoft Access” specifies the type of database containing the table. Following that is the folder location (“root”) of the external database. The variable actable specifies that the object we wish to import is a table. The next two strings contain the table name to import and the name to assign to the imported table when it is imported into the current database. It should be noted that if the table named to be imported already exists in the current database, MS Access will automatically rename the table being imported.
Once the desired tables have been imported, they can be utilized just like any of the other tables in the database.
Rate this Article:
Current: 0 / 5 stars - 0 vote(s).
Article Tags: Development, Programming, Table, Oracle, Microsoft Access, Database, Visual Basic, SQL, Query, Recordset Article Source: http://www.articlesbase.com/programming-articles/importing-external-access-database-tables-using-visual-basic-by-nicholas-brown-566986.html About the Author:
Nicholas Brown is a recognized authority on the subject of Access Databases. He is the founder of Database Technology Services (DTS). DTS is a leader in custom Access database development. DTS programmers create databases for corporations, small businesses and individuals. Visit www.dts-consultants.com to see all of the services DTS has to offer.
Related ArticlesProduct Delivery: Think Like the Customer by Nicholas Brown Database Design Basics by Nicholas Brown Querying Table Data Using Visual Basic Code in Ms Access Becoming an Expert Ms Access Database Programmer Pulling Data From Multiple Tables Into a Single Query in Ms Access by Nicholas Brown Using Comments in Your Programming Source Code by Nicholas Brown Increasing Small Business Productivity by Nicholas Brown Ms Access Databases Don't Have to Look Unprofessional by Nicholas Brown Got a Question? Ask.Ask the community a question about this article:Frequently Asked Questions Database programmer Wher was LaBonge before Dubai design center: question from italy How to form a Christian Showcase? I have a ceiling fan over the area for my pool ... I have a ceiling fan over the area for my pool ... Latest Programming ArticlesCool Desktop Wallpapers Tips for Buying Software Online Mvc Design Pattern Advantages of Low Cost Contract Programmers in Freelance Programming A Guide to Cnc Kits A Guide to Cnc Tube Bending Machines Ways to Hire Dedicated Php Programmers Top 4 Reasons Why Addressing Web Accessibility is Important More from Nicholas BrownDatabase Design Basics by Nicholas Brown Product Delivery: Think Like the Customer by Nicholas Brown Ms Access Databases Don't Have to Look Unprofessional by Nicholas Brown Using Comments in Your Programming Source Code by Nicholas Brown Increasing Small Business Productivity by Nicholas Brown Pulling Data From Multiple Tables Into a Single Query in Ms Access by Nicholas Brown Becoming an Expert Ms Access Database Programmer Querying Table Data Using Visual Basic Code in Ms Access |
|||||||
|
Article Categories
|
|||||||
|
|
|||||||