Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

使用新增按钮打开窗体,可以让窗体中的某个命令按钮不可用吗?

流星  发表于:2015-03-03 19:29:08  
复制

 使用新增按钮打开窗体,可以让窗体中的某个命令按钮不可用吗?

要怎么写这个代码?

 

Top
煮江品茶 发表于:2015-03-04 10:37:24
方法不胜枚举,关键看你为什么(或达到什么条件)使按钮不可用。

麥田 发表于:2015-03-04 13:05:16

可用与不可用代码如下:

控件名.Enabled = False

控件名.Enabled = True


【Access入门】命令按钮按一次后不可用的入门示例,按钮单击后不可用[Access软件网]
http://www.accessoft.com/article-show.asp?id=8038



流星 发表于:2015-03-06 21:00:03

我也是这么做的,但是只能使它不可使用,

我的条件是当鼠标在“提取默认值”上的时候,判断“赎单编号”是否NULL 或空,是的话就是TRUE,否则为FALSE

但是它只能在开始的时候有反应,当输入数据后再清空的时候,就不能判断了,

当“赎单编号”获得焦点的时候,INPUTMASK是不为空的,是这个原因吗?




茼蒿 发表于:2015-03-09 11:42:00

可以把事件写在“赎单编号”的更新后事件中:

if isnull(me.赎单编号) then

  me.提取默认值.Enabled = true

else

 me.提取默认值.Enabled = false

end if



李斌 发表于:2015-03-19 23:10:01

控件名1.Enabled = False

控件名2.Enabled  = False

或者

控件名1.Locked = True
      控件名2.Locked = True




煮江品茶 发表于:2015-03-20 15:55:00

在编号的更新后事件中写:

me.提取默认值.Enabled =isnull(me.赎单编号.value)


如果要同时控制今日付款按钮的可用性,则可以按一下方法处理:

1、写一个自定义函数
function SetBtnEnabled(ctrlname as string)
    dim ctrl as control
    dim B as boolean
    b=true
    for each ctrl in me.controls
        if ctrl.controltype=acComboBox or ctrl.controltype=acTextBox then
            if left(ctrl.controls(0).caption,1)="*" then '找到必填控件
                b=b and isnull(ctrl.value)=false 
                if ctrl.name="赎单编号" then
                    me.提取默认值.Enabled=isnull(ctrl.value) '控制提取默认值按钮的可用性
                end if
            end if
        end if
    next
    me.今日付款.Enabled=b '控制今日付款按钮的可用性
end function


2、在窗体的加载程序中写:
dim ctrl as control
for each ctrl in me.controls
    if ctrl.controltype=acComboBox or ctrl.controltype=acTextBox then
        if left(ctrl.controls(0).caption,1)="*" then
            ctrl.AfterUpdate ="=SetBtnEnabled('" & ctrl.name & "')"
        end if
    end if
next



总记录:6篇  页次:1/1 9 1 :