MS Access:在 DDL 中设置表列标题或说明?
是否可以使用 DDL 在 MS Access 中设置表列的标题或描述属性?理想情况下,我们可以将它们包含在 CREATE TABLE 语句中。
Is it possible to set a table column's Caption or Description properties in MS Access using DDL? Ideally, we could include them in a CREATE TABLE statement.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 DAO 按照 Andrea 建议设置Caption和Description属性。请注意,这两个属性都是用户定义的,而不是默认属性......这意味着它们在为它们分配值之前不存在。
例如,以下语句会触发错误 3270,“找不到属性”,因为我尚未为
id
字段分配描述:要为字段分配Description值,我首先必须为Description
CreateProperty
,然后Append
新属性到字段的Properties集合。我建议您使用 Allen Browne 的 SetPropertyDAO 函数,而不是编写代码来向您展示。该函数将为您处理详细信息。请务必同时获取HasProperty
函数,因为它是由SetPropertyDAO
调用的。 (HasProperty
的代码位于同一网页上,紧邻SetPropertyDAO
函数代码下方。)Use DAO to set Caption and Description properties as Andrea suggested. Just be aware that both those properties are user-defined, not default properties ... meaning that they don't exist before you assign them a value.
For example the following statement triggers error 3270, 'Property not found', because I have not assigned a Description for the
id
field:In order to assign a Description value for the field, I would first have to
CreateProperty
for Description thenAppend
the new property to the field's Properties collection. Rather than write code to show you, I will suggest you use Allen Browne's SetPropertyDAO function. That function will handle the details for you. Be sure to grab theHasProperty
function, too, because it is called bySetPropertyDAO
. (The code forHasProperty
is on the same web page, immediately below theSetPropertyDAO
function code.)遗憾的是,无法通过 Access DDL 更改或设置表或字段的某些属性。我们遇到了类似的问题,还涉及表之间的关系,因此我们求助于 DAO。
无论如何,这很简单,您将使用诸如 DAO.Database、DAO.TableDef 和 DAO.Field 之类的对象。
Alas, it's not possibile to change or set some properties of a table or field by Access DDL. We had a similar problem, involving also relations between tables, and we resorted to DAO.
It' quite simple anyway, you'll be using objects such as
DAO.Database
,DAO.TableDef
andDAO.Field
.