borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Dynamic Footers in Access Reports) New Topic New Poll Post Reply
AndreaVB Forum : Database : ADOX and Access problem!
Poster Message
robertd
Level: Guest


icon ADOX and Access problem!  Archived to Disk

This code is cut from the MSDN Library. Why doesn't the codeline marked as [1] work against Access table? I try to make a "Autonumber" type instead of an adInteger. I also cannot find any Long type.


Sub CreateAutoIncrColumn()

      Dim cat     As New ADOX.Catalog
      Dim tbl     As New ADOX.Table
      Dim col     As New ADOX.Column

   ' Open the catalog
   cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=C:Program FilesMicrosoft Office" & _
      "OfficeSamplesNorthwind.mdb;"

   With tbl
      .Name = "MyContacts"
      Set .ParentCatalog = cat
      ' Create fields and append them to the new Table object.
      .Columns.Append "ContactId", adInteger
      ' Make the ContactId column and auto incrementing column
[1]   .Columns("ContactId").Properties("AutoIncrement") = True
      .Columns.Append "CustomerID", adVarWChar
      .Columns.Append "FirstName", adVarWChar
      .Columns.Append "LastName", adVarWChar
      .Columns.Append "Phone", adVarWChar, 20
      .Columns.Append "Notes", adLongVarWChar
   End With

   cat.Tables.Append tbl

   Set cat = Nothing

End Sub

Regards
Robert Dalan

10-04-2002 at 01:44 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: ADOX and Access problem!  Archived to Disk

I entered the code into an blank Access XP (2000 format however) database, in a module.

Stepped through it (after adding a few more references - the ADOX didn't work until I added its reference).

It worked. So offhand, the code seems valid, maybe you're missing a reference or something.


10-04-2002 at 05:07 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : Database : ADOX and Access problem!
Previous Topic (Dynamic Footers in Access Reports) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder