Office中国论坛/Access中国论坛

标题: [求助]控制所有控件属性,这段代码该怎样改? [打印本页]

作者: fannky    时间: 2006-5-31 21:56
标题: [求助]控制所有控件属性,这段代码该怎样改?
Private Sub But38_Click()
If But38.Caption = "增加" Then
Dim ctr As Control
For Each ctr In Me.sonfrm.Form

If ctr.Type = TextBox Then
With ctr
    .Locked = flase
End With
End If
Next ctr


(就是这段红色代码出问题,我希望让所有的文本框属性变为可写,请大虾帮助)

    With But38
        .Caption = "保存"
        .ForeColor = 255
    End With
   
    Me.sonfrm.Form.DataEntry = True
    Me.sonfrm.Locked = False
   

Else
    Me.sonfrm.Locked = True
    Me.sonfrm.Form.DataEntry = False
'    docmd.RunSQL ""
    With But38
        .Caption = "增加"
        .ForeColor = 0
    End With
End If
End Sub

[此贴子已经被作者于2006-5-31 13:56:17编辑过]


作者: fan0217    时间: 2006-5-31 22:24
用:For Each ctr In Me.Controls试试。

作者: andymark    时间: 2006-5-31 22:48
Dim Ctl As Control
For Each Ctl In Me.Controls
    If (TypeOf Ctl Is TextBox) Then
     Ctl.Locked = True
     End If
   
Next
作者: fannky    时间: 2006-5-31 22:56
以下是引用fan0217在2006-5-31 14:24:00的发言:
用:For Each ctr In Me.Controls试试。





不行啊,还是错误!


指针指在 ctr.Type = TextBox ,下面是错误提示:


[attach]18174[/attach]
请问,当控件类型为文本框,我那样写判断句对吗?




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3