Ms access 使用VBA访问Access 2007中的数据表标题

Ms access 使用VBA访问Access 2007中的数据表标题,ms-access,vba,ms-access-2007,Ms Access,Vba,Ms Access 2007,由于某种原因,关联表字段描述中的文本会自动填充“我的表单”上的“数据表标题”属性,而不是“状态栏文本”属性。我想用这个值更新状态栏文本。我不确定如何在设计模式下引用数据表标题并运行以下代码: 建议 Dim ctl As Control For Each ctl In [Forms]![frmInventory].Controls Select Case ctl.ControlType Case acCommandButton, acCheckBox, acTextBox

由于某种原因,关联表字段描述中的文本会自动填充“我的表单”上的“数据表标题”属性,而不是“状态栏文本”属性。我想用这个值更新状态栏文本。我不确定如何在设计模式下引用数据表标题并运行以下代码:

建议

Dim ctl As Control

For Each ctl In [Forms]![frmInventory].Controls
    Select Case ctl.ControlType
        Case acCommandButton, acCheckBox, acTextBox, acListBox, acComboBox, acToggleButton
        ctl.StatusBarText = ctl.Properties("DataSheetCaption")
    End Select
Next

在表级别,数据表标题是DAO.Field对象中的
.Properties(“标题”)
。(如果没有为该字段定义自定义标题,则该字段可能不存在。)

该属性不会直接复制到窗体上的数据控件。也就是说,文本框控件在
.Properties(“caption”)
中没有标题。相反,标题位于附加到文本框控件的标签的
.caption

因此,如果要将字段的数据表标题复制到控件的状态栏文本,可能必须

  • 从控件的
    .ControlSource
    获取字段的名称
  • TableDef
    对象的
    Fields
    集合中查找该字段,然后
  • 从字段对象的
    .Properties(“caption”)
    属性(如果存在)中提取标题