|
|
Subject:
Autonumber Field in Microsoft Access database
Category: Computers > Programming Asked by: gravey-ga List Price: $5.00 |
Posted:
17 Oct 2002 21:36 PDT
Expires: 16 Nov 2002 20:36 PST Question ID: 80022 |
How can I create a new field in a access table using ADOX, and tell it to be a random autoincrement field. It must be using ADOX, and it must generate a random field similar to selecting random autonumber directly in access. |
|
Subject:
Re: Autonumber Field in Microsoft Access database
Answered By: iaint-ga on 18 Oct 2002 03:22 PDT Rated: |
Hi gravey I found an article which indicates that what you want to do *is* possible, but it's not a simple procedure: "[it wasn't] appropriate for the designers of ADOX to include an AutoNumber or IdentityColumn property of the Column object. Instead, to gain access to this data-source-specific functionality, you must use dynamic properties." http://www.devx.com/upload/free/features/vbpj/1999/06jun99/jm0699/jm0699.asp A couple of paragraphs later the same page gives some sample code for creating an AutoIncrement field: Set col = New ADOX.Column Set col.ParentCatalog = cat With col .Type = adInteger .Name = "ID" .Properties("Autoincrement") = True End With tbl.Columns.Append col OK, but you want to make this generate a *random* number automatically. A little more searching locates an archived thread of posts which reveals what else we need to add within the With..End With block: http://p2p.wrox.com/archive/pro_vb/2001-09/12.asp .Properties("Default").Value = "GenUniqueID()" .Properties("Fixed Length").Value = True .Properties("Jet OLEDB:AutoGenerate").Value = True I hope this lets you achieve what you require, and good luck with the rest of your application development! Regards iaint-ga Search criteria (on Google): adox autonumber adox column autonumber random |
gravey-ga
rated this answer:
Thanks for the answer, sorry i took a while to try it, but it does work. |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |