Foxtable(狐表)用户栏目专家坐堂 → [求助]sql空值和null的问题


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

主题:[求助]sql空值和null的问题

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/27 17:21:00 [显示全部帖子]

Dim StartDate As Date
Dim EndDate As Date
StartDate =RibbonTabs("基础成本").Groups("查找").Items("开始日期").value
EndDate = RibbonTabs("基础成本").Groups("查找").Items("结束日期").value

Dim filter As String = "1=1"
If startDate <> Nothing Then
    filter &= " and [inputdate] >= #" & StartDate & "#"
End If
If EndDate <> Nothing Then
    filter &= " And [inputdate] <= #" & EndDate & "#"
End If

Dim sts() As String = {"BCID","input","usercode","fullname"}
For Each st As String In sts
    Dim var As String = RibbonTabs("基础成本").Groups("查找").Items(st).text
    If var IsNot Nothing  Then
        var = var.Replace("*","[*]")
        filter =filter & " and " & st & " Like '%" & var & "%'"
    End If
Next
Tables("Basecost").Filter = filter


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/28 10:49:00 [显示全部帖子]

1、msgbox(filter) 看弹出的条件是否正确。

 

2、试试

 

Dim StartDate As Date
Dim EndDate As Date
StartDate =RibbonTabs("基础成本").Groups("查找").Items("开始日期").value
EndDate = RibbonTabs("基础成本").Groups("查找").Items("结束日期").value

Dim filter As String = "1=1"
If startDate <> Nothing Then
    filter &= " and [inputdate] >= #" & StartDate & "#"
End If
If EndDate <> Nothing Then
    filter &= " And [inputdate] <= #" & EndDate & "#"
End If
Dim sts() As String = {"BCID","input","usercode","fullname"}
For Each st As String In sts
    Dim var As String = RibbonTabs("基础成本").Groups("查找").Items(st).text
    If var = Nothing  Then
        '不操作
    Else
        var = var.Replace("*","[*]")
        filter =filter & " and " & st & " Like '%" & var & "%'"
    End If
Next
Tables("Basecost").Filter = filter


 回到顶部