是否可以通过VBA以编程方式访问标签?我想创建使用for循环多个标签,如该图所示这将设置名为“Label1的”到“Label20”的所有标签可见以编程方式访问和设置标签属性的MS Access vba
for a_counter = 1 to 20
Me.Label(a_counter).Visible = True
next a_counter
是如上述可能这样的东西?
是否可以通过VBA以编程方式访问标签?我想创建使用for循环多个标签,如该图所示这将设置名为“Label1的”到“Label20”的所有标签可见以编程方式访问和设置标签属性的MS Access vba
for a_counter = 1 to 20
Me.Label(a_counter).Visible = True
next a_counter
是如上述可能这样的东西?
您可以通过表单的Controls集合中的名称引用每个标签控件“Label1”到“Label20”。
For a_counter = 1 To 20
Me.Controls("Label" & a_counter).Visible = True
Next a_counter
标签是访问表单中的一种特定类型的控件。你应该能够写下这样的代码:
function listLabels()
dim m_ctl as control
for each m_ctl in screen.activeForm.controls
if m_ctl.type = .... 'please check the control types available!
debug.print m_ctl.name
end if
next m_ctl
end function
要小心。我甚至不确定控件的属性(.type,.name),但您可以在帮助中轻松找到它们。寻找“控制”对象。
非常感谢 – icweb 2012-03-13 20:54:07