Microsoft Office Tutorials and References
In Depth Information
Creating a New Table in Access
crEATing A nEW TABlE in AccEss
Suppose you are managing a project that involves both Excel and Access, and you need to add a new
table to the Access database. You can do that with the following macro, and from there if need be,
using the first macro in this lesson named ExcelToAccess , you can transfer any records you may
have accumulated for that new table.
In this example, you create a simple three-field table that will maintain a company’s Employee
Identification Number, which will be a Primary Field, and the employees’ last names and first
names. The new table is named tblEmployees, and it is added to the Database1.accdb file that’s
been the subject of this lesson. Figure 29-2 shows Database1.accdb with the new table added after
running the following macro named CreateAccessTable .
‘Create a three-column table in an existing Access database:
Dim dbConnection As ADODB.Connection
Dim dbCommand As ADODB.Command
Dim dbFileName As String
‘Define the Access database path and name.
dbFileName = “C:\YourFilePath\Database1.accdb”