Foxtable(狐表)用户栏目专家坐堂 → 查询


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

主题:查询

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


加好友 发短信
等级:一尾狐 帖子:407 积分:3087 威望:0 精华:0 注册:2014/6/10 11:31:00
查询  发帖心情 Post By:2017/6/16 14:20:00 [只看该作者]

Dim Filter20 As String

With e.Form.Controls("起始时间")
    If .Value IsNot Nothing Then
        If Filter20 >"" Then
            Filter20 = Filter20 & " And "
        End If
        Filter20 = Filter20 & "日期 >= #" & .Value & "#"
       

    End If
End With
With e.Form.Controls("结束时间")
    If .Value IsNot Nothing Then
        If Filter20 >"" Then
            Filter20 = Filter20 & " And "
        End If
        Filter20 = Filter20 & "日期 <= #" & .Value & "#"
       
     End If
End With
If Filter20 > "" Then
    Tables("車鲁H7A751").Filter = Filter20
   End If

Dim sum11, sum12, sum13, sum14, sum15 As Double
sum11 = Tables("車鲁H7A751").Compute("sum(支公司款)")
sum12 = Tables("車鲁H7A751").Compute("sum(特殊费用)")
sum13 = Tables("車鲁H7A751").Compute("sum(现金运费)")
sum14 = Tables("車鲁H7A751").Compute("sum(金额)")
sum15 = Tables("車鲁H7A751").Compute("sum(工资)")
e.Form.Controls("合计结果1").Text = format(sum11 + sum12 + sum13  - sum14 - sum15, "#.00")

Dim Filter As String = "1=1"
Dim filter2 As String = "1=1"
Dim filter3 As String = "1=1"
Dim filter4 As String = "1=1"
Dim cname As String = ""
With e.Form.Controls("承运")
    If .Value IsNot Nothing Then
        Filter &= " and 承运单位 = '" & .Value & "'"
        Filter2 &= " and 托运单位 = '" & .Value & "'"
        Filter3 &= " and 欠款人 = '" & .Value & "'"
        Filter4 &= " and 交款单位 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("起始时间")
    If .Value IsNot Nothing Then
        Filter &= " And 日期 >= #" & .Value & "#"
        filter2 &= " and " & "日期 >= #" & .Value & "#"
        filter3 &= " and " & "日期 >= #" & .Value & "#"
        filter4 &= " and " & "日期 >= #" & .Value & "#"
    End If
    cname &= "(" & .Value & "-"
End With
With e.Form.Controls("结束时间")
    If .Value IsNot Nothing Then
        Filter &= " and 日期 <= #" & .Value & "#"
        filter2 &= " and " & "日期 <= #" & .Value & "#"
        filter3 &= " and " & "日期 <= #" & .Value & "#"
        filter4 &= " and " & "日期 <= #" & .Value & "#"
    End If
    cname &= .Value & ")"
End With

DataTables("应付款明细").DataRows.Clear
DataTables("应付款明细").DataCols("金额").Caption = cname & "金额"
DataTables("应付款明细").BuildHeader
For Each cys As String In DataTables("应付").GetValues("承运单位", filter)
    Dim ndr As DataRow = DataTables("应付款明细").AddNew
    ndr("承运单位") = cys
    Dim sum1, sum2, sum3, sum4 As Double
    sum1 = DataTables("应付").Compute("sum(金额)", filter & " and 承运单位 = '" & cys & "'")
    sum2 = DataTables("应收").Compute("sum(金额)", filter2 & " and 托运单位 = '" & cys & "'")
    sum3 = DataTables("扣款录入").Compute("sum(金额)", filter3 & " and 欠款人 = '" & cys & "'")
    sum4 = DataTables("已收款录入").Compute("sum(金额)", filter4 & " and 交款单位 = '" & cys & "'")
    ndr("金额") = format(sum2 + sum3 - sum1 - sum4, "0.00")
Next

If Filter > "" Then
    Tables("应付").Filter = Filter
   End If
Tables("应付.扣款录入").Filter = filter3
Tables("应付.应收").Filter = filter2
Tables("应付.已收款录入").Filter = filter4

Dim sum5, sum6, sum7, sum8 As Double
sum5 = Tables("应付").Compute("sum(金额)")
sum6 = Tables("应付.应收").Compute("sum(金额)")
sum7 = Tables("应付.已收款录入").Compute("sum(金额)")
sum8 = Tables("应付.扣款录入").Compute("sum(金额)")
e.Form.Controls("合计结果2").Text = format(sum5 + sum7 - sum6 - sum8, "0.00")
e.Form.Controls("合计结果3").Text = format((sum11 + sum12 + sum13  - sum14 - sum15+sum5 + sum7 - sum6 - sum8)/2-(sum11 + sum12 + sum13  - sum14 - sum15), "#.00")
e.Form.Controls("合计结果").Text = format(sum11 + sum12 + sum13  - sum14 - sum15+sum5 + sum7 - sum6 - sum8, "#.00")

 

 

 

Dim Filter20 As String

With e.Form.Controls("起始时间")
    If .Value IsNot Nothing Then
        If Filter20 >"" Then
            Filter20 = Filter20 & " And "
        End If
        Filter20 = Filter20 & "日期 >= #" & .Value & "#"
       

    End If
End With
With e.Form.Controls("结束时间")
    If .Value IsNot Nothing Then
        If Filter20 >"" Then
            Filter20 = Filter20 & " And "
        End If
        Filter20 = Filter20 & "日期 <= #" & .Value & "#"
       
     End If
End With
If Filter20 > "" Then
    Tables("車鲁H7H169").Filter = Filter20
   End If

Dim sum11, sum12, sum13, sum14, sum15 As Double
sum11 = Tables("車鲁H7H169").Compute("sum(支公司款)")
sum12 = Tables("車鲁H7H169").Compute("sum(特殊费用)")
sum13 = Tables("車鲁H7H169").Compute("sum(现金运费)")
sum14 = Tables("車鲁H7H169").Compute("sum(金额)")
sum15 = Tables("車鲁H7H169").Compute("sum(工资)")
e.Form.Controls("合计结果1").Text = format(sum11 + sum12 + sum13  - sum14 - sum15, "#.00")

Dim Filter As String = "1=1"
Dim filter2 As String = "1=1"
Dim filter3 As String = "1=1"
Dim filter4 As String = "1=1"
Dim cname As String = ""
With e.Form.Controls("承运")
    If .Value IsNot Nothing Then
        Filter &= " and 承运单位 = '" & .Value & "'"
        Filter2 &= " and 托运单位 = '" & .Value & "'"
        Filter3 &= " and 欠款人 = '" & .Value & "'"
        Filter4 &= " and 交款单位 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("起始时间")
    If .Value IsNot Nothing Then
        Filter &= " And 日期 >= #" & .Value & "#"
        filter2 &= " and " & "日期 >= #" & .Value & "#"
        filter3 &= " and " & "日期 >= #" & .Value & "#"
        filter4 &= " and " & "日期 >= #" & .Value & "#"
    End If
    cname &= "(" & .Value & "-"
End With
With e.Form.Controls("结束时间")
    If .Value IsNot Nothing Then
        Filter &= " and 日期 <= #" & .Value & "#"
        filter2 &= " and " & "日期 <= #" & .Value & "#"
        filter3 &= " and " & "日期 <= #" & .Value & "#"
        filter4 &= " and " & "日期 <= #" & .Value & "#"
    End If
    cname &= .Value & ")"
End With

DataTables("应付款明细").DataRows.Clear
DataTables("应付款明细").DataCols("金额").Caption = cname & "金额"
DataTables("应付款明细").BuildHeader
For Each cys As String In DataTables("应付").GetValues("承运单位", filter)
    Dim ndr As DataRow = DataTables("应付款明细").AddNew
    ndr("承运单位") = cys
    Dim sum1, sum2, sum3, sum4 As Double
    sum1 = DataTables("应付").Compute("sum(金额)", filter & " and 承运单位 = '" & cys & "'")
    sum2 = DataTables("应收").Compute("sum(金额)", filter2 & " and 托运单位 = '" & cys & "'")
    sum3 = DataTables("扣款录入").Compute("sum(金额)", filter3 & " and 欠款人 = '" & cys & "'")
    sum4 = DataTables("已收款录入").Compute("sum(金额)", filter4 & " and 交款单位 = '" & cys & "'")
    ndr("金额") = format(sum2 + sum3 - sum1 - sum4, "0.00")
Next

If Filter > "" Then
    Tables("应付").Filter = Filter
   End If
Tables("应付.扣款录入").Filter = filter3
Tables("应付.应收").Filter = filter2
Tables("应付.已收款录入").Filter = filter4

Dim sum5, sum6, sum7, sum8 As Double
sum5 = Tables("应付").Compute("sum(金额)")
sum6 = Tables("应付.应收").Compute("sum(金额)")
sum7 = Tables("应付.已收款录入").Compute("sum(金额)")
sum8 = Tables("应付.扣款录入").Compute("sum(金额)")
e.Form.Controls("合计结果2").Text = format(sum5 + sum7 - sum6 - sum8, "0.00")
e.Form.Controls("合计结果3").Text = format((sum11 + sum12 + sum13  - sum14 - sum15+sum5 + sum7 - sum6 - sum8)/2-(sum11 + sum12 + sum13  - sum14 - sum15), "#.00")
e.Form.Controls("合计结果").Text = format(sum11 + sum12 + sum13  - sum14 - sum15+sum5 + sum7 - sum6 - sum8, "#.00")

 

 上述查询按钮中的代码如何修改才能实现下表中的内容

 


图片点击可在新窗口打开查看此主题相关图片如下:3333333.png
图片点击可在新窗口打开查看

 


 


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


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/16 14:57:00 [只看该作者]

最后写

 

Dim nr As DataRow = DataTables("表A").AddNew

nr("第一列") = "xxx"

nr("第二列") = format(sum11 + sum12 + sum13  - sum14 - sum15+sum5 + sum7 - sum6 - sum8, "#.00")


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


加好友 发短信
等级:一尾狐 帖子:407 积分:3087 威望:0 精华:0 注册:2014/6/10 11:31:00
回复:(有点色)最后写 Dim nr As DataRow ...  发帖心情 Post By:2017/6/16 15:23:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:9999999999.png
图片点击可在新窗口打开查看

 

在最后加上代码后 点查询出现这个


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


加好友 发短信
等级:一尾狐 帖子:407 积分:3087 威望:0 精华:0 注册:2014/6/10 11:31:00
回复:(有点色)最后写 Dim nr As DataRow ...  发帖心情 Post By:2017/6/16 16:09:00 [只看该作者]

帮我看下老师  我研究2天了图片点击可在新窗口打开查看

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


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/16 16:42:00 [只看该作者]

类似这种的代码,都删除 e.Form.Controls("合计结果1").Text

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


加好友 发短信
等级:一尾狐 帖子:407 积分:3087 威望:0 精华:0 注册:2014/6/10 11:31:00
回复:(有点色)类似这种的代码,都删除 e.Form.Cont...  发帖心情 Post By:2017/6/16 16:58:00 [只看该作者]

e.Form.Controls("合计结果1").Text = format(sum11 + sum12 + sum13  - sum14 - sum15, "#.00")

 

删除之后  = 号前边怎么写


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


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/16 18:19:00 [只看该作者]

 不用写,直接删除。

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


加好友 发短信
等级:一尾狐 帖子:407 积分:3087 威望:0 精华:0 注册:2014/6/10 11:31:00
回复:(有点色) 不用写,直接删除。  发帖心情 Post By:2017/6/16 18:46:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:00000000000.png
图片点击可在新窗口打开查看

 

删除后出现这个


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


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

是整行都删除,不仅仅是=号前的

 回到顶部