This article applies to a Microsoft Access database (.mdb) file or to a Microsoft Access database (.accdb) file.
For a Microsoft Access 2000 version of this article, see 209037 .
NOTE: All the examples in this article assume that you add the statements to an Access query and that you run them by clicking Run.
- Create a new query in a Access database.
- On the Query menu, point to SQL Specific, and then click Data Definition.
Note In Access 2007, click Data Definition in the Query Type group on the Design tab.
- Enter your data definition statement in the Data Definition Query window, and then run the query by clicking Run on the Query menu.
Note In Access 2007, enter your data definition statement in the Data Definition Query window, and then run the query by clicking Run in the Results group on the Design tab.
NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.
Sub ExecuteSQLDDL (SQLString As String)
Dim db As DAO.Database, qd As DAO.QueryDef
Set db = DBEngine.Workspaces(0).Databases(0)
Set qd = db.CreateQueryDef("")
qd.SQL = SQLString
Article ID: 291539 - Last Review: Oct 30, 2008 - Revision: 1