MS Access:在 DDL 中设置表格列标题或说明? [英] MS Access: setting table column Caption or Description in 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.
推荐答案
按照 Andrea 的建议,使用 DAO 设置 Caption 和 Description 属性.请注意, Caption 和 Description 都是用户定义的,而不是默认属性……这意味着在为它们分配值之前它们不存在.
Use DAO to set Caption and Description properties as Andrea suggested. Just be aware that both Caption and Description are user-defined, not default properties ... meaning that they don't exist before you assign them a value.
例如,以下语句会触发错误 3270,未找到属性",因为我尚未为 id 字段分配描述:
For example the following statement triggers error 3270, 'Property not found', because I have not assigned a Description for the id field:
Debug.Print CurrentDb.TableDefs("tblFoo").Fields("id").Properties("Description")
为了为该字段分配一个描述值,我首先必须为描述"CreateProperty
,然后将新属性Append
添加到该字段的Properties
集合.与其编写代码来向您展示,我建议您使用 Allen Browne 的 SetPropertyDAO 函数.该函数将为您处理详细信息.一定要获取HasProperty
函数,因为它被SetPropertyDAO
调用.(HasProperty
的代码在同一个网页上,紧接在 SetPropertyDAO
函数代码的下方.)
In order to assign a Description value for the field, I would first have to CreateProperty
for "Description" then Append
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 the HasProperty
function, too, because it is called by SetPropertyDAO
. (The code for HasProperty
is on the same web page, immediately below the SetPropertyDAO
function code.)
这篇关于MS Access:在 DDL 中设置表格列标题或说明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!