Office中国论坛/Access中国论坛

标题: 请教!如何能简化这个查询条件? [打印本页]

作者: sxgaobo    时间: 2009-5-2 09:47
标题: 请教!如何能简化这个查询条件?
If Not IsNull([单位名称]) Or Not IsNull([登记时间]) Or Not IsNull([地址]) Or Not IsNull([法人代表]) Or _
   Not IsNull([简并征期]) Or Not IsNull([经营范围]) Or Not IsNull([开业时间]) Or Not IsNull([联系电话]) Or _
   Not IsNull([纳税人识别号]) Or Not IsNull([现状]) Or Not IsNull([信用等级]) Or Not IsNull([行业]) Or _
   Not IsNull([性质]) Or Not IsNull([征收方式]) Then

窗体中所有 文本框 中只要有一个不为空时给出提示!
作者: Henry D. Sy    时间: 2009-5-2 09:54
dim ctl as control
for each ctl in me.controls
if typeof ctl is textbox then
if not isnull(ctl) then
msgbox "Not Null"
end if
end if
next
作者: sxgaobo    时间: 2009-5-2 11:34
谢谢版主!
如果还有组合框怎么判断啊?
作者: Henry D. Sy    时间: 2009-5-2 13:55
Dim ctl As Control
    For Each ctl In Me.Controls
        If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
            If Not IsNull(ctl) Then
                MsgBox "Not Null"
                Exit For
            End If
        End If
    Next
作者: sxgaobo    时间: 2009-5-3 08:43
谢谢版主了!
再多问句,如果反过来怎么做啊!就是说当窗体中所有文本框和组合框都为空的时候给出提示。
作者: Henry D. Sy    时间: 2009-5-3 10:38
Dim ctl As Control
    Dim intCount As Integer, intNullCount As Integer
    For Each ctl In Me.Controls
        If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
            intCount = intCount + 1
            If IsNull(ctl) Then
                intNullCount = intNullCount + 1
            End If
        End If
    Next
    If intCount = intNullCount Then
        MsgBox "All Null"
    End If
作者: Henry D. Sy    时间: 2009-5-3 10:52
dddddddd
作者: sxgaobo    时间: 2009-5-4 10:07
谢谢版主!
搞定




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