VBA for Access 2003 - 用于创建访问文件的 DDL:设置自动编号数据类型
所以我有下面的VB,它在默认工作区中创建一个访问文件,创建一个表,在该表中创建一些字段...只需要知道将第一个数据类型/字段设置为自动编号的语法...GUID,计数器等不会像 Access SQL 中那样工作,
' error handling usually goes here
dim ws as workspace
dim dbExample as database
dim tblMain as TableDef
dim fldMain as Field
dim idxMain as Index
set ws = workspace(0)
set dbExample = ws.CreateDatabase('string file path')
set tblMain = dbExample.CreateTableDef("tblMain")
set fldMain = tblMain.CreateField("ID", 'right here I do not know what to substitute for dbInteger to get the autonumber type to work )
tblMain.Fields.Append fldMain
etc to create other fields and indexes
因此在这一行中: 设置 fldMain = tblMain.CreateField("ID", dbInteger) 我需要将 dbInteger 替换为 VB 识别为自动编号属性的内容。 我已经尝试过 GUID、计数器、自动编号、自动增量......不幸的是,这些工作都没
有人知道我在这里缺少的语法吗?
谢谢, 贾斯汀
So I have the below VB that creates an access file in the default workspace, creates a table, create some fields in that table...just need to know the syntax for setting the first data type/field to autonumber...GUID, Counter, etc will not work as in Access SQL
' error handling usually goes here
dim ws as workspace
dim dbExample as database
dim tblMain as TableDef
dim fldMain as Field
dim idxMain as Index
set ws = workspace(0)
set dbExample = ws.CreateDatabase('string file path')
set tblMain = dbExample.CreateTableDef("tblMain")
set fldMain = tblMain.CreateField("ID", 'right here I do not know what to substitute for dbInteger to get the autonumber type to work )
tblMain.Fields.Append fldMain
etc to create other fields and indexes
so in this line:
set fldMain = tblMain.CreateField("ID", dbInteger)
i need to replace the dbInteger with something that VB reconizes as the autonumber property.
i have tried GUID, Counter, Autonumber, AutoIncrement....unfortunately none of these work
anyone know the syntax I am missing here?
Thanks,
Justin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅访问网站上的从代码创建自动编号字段。
以下是该链接页面的关键行:
顺便说一句,您所做的不是 DDL。
See Creating an AutoNumber field from code at The access Web.
Here are the key lines from that linked page:
BTW, what you're doing is not DDL.