Foxtable(狐表)用户栏目专家坐堂 → [求助]关于 复选组合框 的查询公式


  共有2745人关注过本帖树形打印复制链接

主题:[求助]关于 复选组合框 的查询公式

帅哥哟,离线,有人找我吗?
wumingrong1
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1029 积分:6497 威望:0 精华:0 注册:2014/1/3 12:49:00
[求助]关于 复选组合框 的查询公式  发帖心情 Post By:2015/8/31 16:29:00 [只看该作者]

如果我的查询界面中存在一个  CheckedComboBox 控件,我以下的查询命令该怎么修改?


图片点击可在新窗口打开查看此主题相关图片如下:360截图20150831162841306.jpg
图片点击可在新窗口打开查看





vars("查询") = True
Dim flt As String
For Each c As Col In Tables("抢修整治迁改表").Cols
    For Each ctl As WinForm.Control In e.Form.Controls
        If c.Name = ctl.Name Then
            If e.Form.Controls(ctl.Name).Text > "" Then
                If c.IsDate Then
                    flt + = " And " & c.Name & " = #" & e.Form.Controls(ctl.Name).Text & "#"
                ElseIf c.IsString Then
                    flt + = " And " & c.Name & " Like '%" & e.Form.Controls(ctl.Name).Text & "%'"
                    
                ElseIf c.IsBoolean AndAlso e.Form.Controls(ctl.Name).Checked Then
                    'msgbox(c.Name)
                    flt + = " And " & c.Name & " = " & e.Form.Controls(ctl.Name).Checked
                    
                End If
            End If
        End If
    Next
Next
If flt > "" Then
    flt = flt.SubString(5)
Else
    MessageBox.Show("请输入查询条件")
End If
Tables("抢修整治迁改表").Filter = flt
vars("查询") = False

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/8/31 16:47:00 [只看该作者]

vars("查询") = True
Dim flt As String
For Each c As Col In Tables("抢修整治迁改表").Cols
    For Each ctl As WinForm.Control In e.Form.Controls
        If c.Name = ctl.Name Then
            If e.Form.Controls(ctl.Name).Text > "" Then
                If c.IsDate Then
                    flt + = " And " & c.Name & " = #" & e.Form.Controls(ctl.Name).Text & "#"
                ElseIf c.IsString Then
                    If typeof ctl Is WinForm.CheckedComboBox Then
                        flt + = " And " & c.Name & " in ('" & e.Form.Controls(ctl.Name).Text.replace(",", "','") & "')"
                    Else
                        flt + = " And " & c.Name & " Like '%" & e.Form.Controls(ctl.Name).Text & "%'"
                    End If

                   
                ElseIf c.IsBoolean AndAlso e.Form.Controls(ctl.Name).Checked Then
                    'msgbox(c.Name)
                    flt + = " And " & c.Name & " = " & e.Form.Controls(ctl.Name).Checked
                   
                End If
            End If
        End If
    Next
Next
If flt > "" Then
    flt = flt.SubString(5)
Else
    MessageBox.Show("请输入查询条件")
End If
Tables("抢修整治迁改表").Filter = flt
vars("查询") = False


 回到顶部
帅哥,在线噢!
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107721 积分:547938 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2015/8/31 16:53:00 [只看该作者]

 If c.Name = ctl.Name Then
    if TypeOf ctl is WinForm.CheckedComboBox Then
      if  e.Form.Controls(ctl.Name).Text > "" then 
       dim s() as string =  e.Form.Controls(ctl.Name).Text.Split(",")
         dim f as string = "1=2"
         for each s1 as string in s
           f + = " Or " & c.Name & " Like '%" & s1 & "%'"
         next
          flt + = "And (" & f & ")"
      end if
    else
       你的代码
    end if     
end if
[此贴子已经被作者于2015/8/31 16:54:17编辑过]

 回到顶部