设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 2450|回复: 6
打印 上一主题 下一主题

[模块/函数] [求助]如何用通用模块改变窗体中所有文本框组合框的背景色?

[复制链接]
1#
发表于 2006-1-24 03:54:00 | 显示全部楼层
给你个Access帮助里面示例:

示例

以下示例检查窗体上所有控件的 ControlType 属性。对所有标签和文本框控件,该过程切换其“SpecialEffect”属性。当标签的“特殊效果”属性设置为“凹陷”,且文本框的“特殊效果”属性设置为“普通”,AllowAdditionsAllowDeletionsAllowEdits 属性均设置为 True,则
  1. intCanEdit
复制代码
变量将切换为允许编辑基础数据。
  1. 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编辑过]

2#
发表于 2006-1-24 21:46:00 | 显示全部楼层
把你的代码写成函数,然后在你需要的地方调用就可以了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-23 17:28 , Processed in 0.089632 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表