ACC2000: How to Create a Table with Jet Data Types via ADOX

This article was previously published under Q275252
This article has been archived. It is offered "as is" and will no longer be updated.
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access database (.mdb).

This article contains an ActiveX Extensibility Objects (ADOX) example that demonstrates a way to create a native Jet table with some of the common Jet data types and properties.
More information
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following Visual Basic for Applications example creates in the current database a table with some of the common data types and properties, such as AutoNumber, Decimal, Memo, and Text.

NOTE: Before you run the code, click References on the Tools menu, and make sure that you have the following reference selected:
Microsoft ADO Ext. 2.x for DDL and Security
Sub ADOX_CreateJetTable()'This example demonstrates creating a Jet table with'Autoincrement, Decimal, and Memo columns.Dim tbl As New ADOX.TableDim cat As New ADOX.Catalog'Return Reference to current database.Set cat.ActiveConnection = CurrentProject.Connection'Assign the new table name.With tbl  .Name = "MyNewTable"    ' Append new columns to the table.    With .Columns      .Append "MyID", adInteger      .Append "MyMemo", adLongVarWChar      .Append "MyVarChar", adWChar, 50      .Append "MyDecimal", adNumeric                'After appending columns, set            'provider specific properties.            With !MyID                Set .ParentCatalog = cat                    .Properties("Autoincrement") = True                    .Properties("seed") = CLng(20)                    .Properties("increment") = CLng(20)            End With                    With !MyDecimal                Set .ParentCatalog = cat                    .Precision = 2                    .NumericScale = 1            End With                With !MyVarChar                Set .ParentCatalog = cat                    .Properties("Jet OLEDB:Compressed " _                                & "UniCode Strings") = True            End With        End WithEnd With' Append new table to the provider catalog and clean tblSet cat = NothingEnd Sub				

Article ID: 275252 - Last Review: 10/26/2013 00:26:00 - Revision: 4.0

Microsoft Access 2000 Standard Edition

  • kbnosurvey kbarchive kbhowto KB275252