I copied the CreateAutoNumberField routine from MSDN and pasted it into a new project as shown. I've included "Microsoft ActiveX Data Objects Recordset 2.7 Library" msador15.dll and "Microsoft ADO Ext. 2.7 for DLL and Security" msadox.dll.

The line in red show the error "Property 'Item' is 'ReadOnly'".

Can anyone help?

VB Code:
  1. Imports ADOX
  2. Imports ADOX.DataTypeEnum
  3. Imports ADOX.KeyTypeEnum
  4.  
  5. Public Class Form1
  6.  
  7.     Inherits System.Windows.Forms.Form
  8.  
  9. #Region " Windows Form Designer generated code "
  10. #End Region
  11.  
  12.     Sub CreateAutoNumberField(ByVal strDBPath As String)
  13.         Dim catDB As ADOX.Catalog
  14.         Dim tbl As ADOX.Table
  15.  
  16.         catDB = New ADOX.Catalog()
  17.         ' Open the catalog.
  18.         catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  19.            "Data Source=" & strDBPath
  20.  
  21.         tbl = New ADOX.Table()
  22.         With tbl
  23.             .Name = "Contacts"
  24.             .ParentCatalog = catDB
  25.             ' Create fields and append them to the
  26.             ' Columns collection of the new Table object.
  27.             With .Columns
  28.                 .Append("ContactId", adInteger)
  29.                 ' Make the ContactId field auto-incrementing.
  30. [COLOR=red]                .Item("ContactId").Properties("AutoIncrement") = True[/COLOR]
  31.                 .Append("CustomerID", adVarWChar)
  32.                 .Append("FirstName", adVarWChar)
  33.                 .Append("LastName", adVarWChar)
  34.                 .Append("Phone", adVarWChar, 20)
  35.                 .Append("Notes", adLongVarWChar)
  36.             End With
  37.         End With
  38.  
  39.         ' Add the new Table to the Tables collection of the database.
  40.         catDB.Tables.Append(tbl)
  41.  
  42.         catDB = Nothing
  43.     End Sub
  44.  
  45. End Class