是否可以通過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