Access穫取被點擊的標籤控件標題

2018-10-12 16:57:00
roych
原創
1424
論罎有老用戶提問到關於顯示點擊的控件問題,卽窗體中有若榦標籤(label),如何能知道當前被點擊的是哪箇?

如下圖所示,當點擊標籤時,顯示點擊到標籤標題


版主roych在一番斥責後,給齣瞭答案,用onclick對象返迴“屬性”窗口中“單擊”框的值

Private Sub Form_Load()
    Dim ctl As Control
    For Each ctl In Me.Controls
        If ctl.ControlType = acLabel Then
            ctl.OnClick = "=Label_Click([" & ctl.Name & "])"
        End If
    Next
End Sub


Function Label_Click(ByRef lbl As Label)
    MsgBox "你點擊瞭" & lbl.Caption
End Function



穫取效果如圖所示:

    分享