通过字符串提供控制名称

问题描述 投票:0回答:1

“Me.strLblName.FontBold =真”是行不通的。我已经试过我。与其他许多人strLblName&.FontBold =真。这是一个语法的事情还是我需要另一种方法是什么?

**Private Sub Form_Load()
Dim ctl As Control, intUsage As Integer, strCtlName As String, strLblName As String
For Each ctl In Me.Form.Controls
    Select Case ctl.ControlType
        Case acCommandButton
            intUsage = DLookup("process_usage", "tbl_db_stats", "cbtn_name = '" & ctl.Name & "'")
            Debug.Print ctl.ControlType, ctl.Name, intUsage
            strLblName = "lbl_" & Right(ctl.Name, Len(ctl.Name) - 5)
            If intUsage < 10 Then
                Stop
                'CHANGE LABEL TEXT TO BOLD
                Me.strLblName.FontBold = True
            End If
    End Select
Next ctl
End Sub**
access-vba
1个回答
0
投票
Controls(strLblName).FontBold = True
© www.soinside.com 2019 - 2024. All rights reserved.