给你个Access帮助里面示例:
示例
以下示例检查窗体上所有控件的 ControlType 属性。对所有标签和文本框控件,该过程切换其“SpecialEffect”属性。当标签的“特殊效果”属性设置为“凹陷”,且文本框的“特殊效果”属性设置为“普通”,AllowAdditions、AllowDeletions 和 AllowEdits 属性均设置为 True,则变量将切换为允许编辑基础数据。- Sub ToggleControl(frm As Form)
Dim ctl As Control
Dim intI As Integer, intCanEdit As Integer
Const conTransparent = 0
Const conWhite = 16777215
For Each ctl in frm.Controls
With ctl
Select Case .[b]ControlType[/b]
Case acLabel
If .SpecialEffect = acEffectShadow Then
.SpecialEffect = acEffectNormal
.BorderStyle = conTransparent
intCanEdit = True
Else
.SpecialEffect = acEffectShadow
intCanEdit = False
End If
Case acTextBox
If .SpecialEffect = acEffectNormal Then
.SpecialEffect = acEffectSunken
.BackColor = conWhite
Else
.SpecialEffect = acEffectNormal
.BackColor = frm.Detail.BackColor
End If
End Select
End With
Next ctl
If intCanEdit = IFalse Then
With frm
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
End With
Else
With frm
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
End If
End Sub
复制代码
[此贴子已经被作者于2006-1-23 19:53:56编辑过]
|