以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  窗口中的表重新计算  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=81125)

--  作者:kaituozhe
--  发布时间:2016/2/19 6:09:00
--  窗口中的表重新计算

 e.DataRow("汇总金额")=DataTables("明细表").SQLCompute("sum(借方金额)",“交易户名= \'" & e.DataRow("交易户名") & "\'and 交易日期 >= #" & forms("统计汇总").controls("开始日期") & "# and 交易日期 <= #" & forms("统计汇总").controls("截止日期") & "#") 上述代码有什么问题吗?执行时总是提交出错误,提示如下:


没有为 字符串“交易户名= \'张三\'and 交易日期 >= #” 和 类型“DateTimePicker” 定义运算符“&”。


--  作者:新福星
--  发布时间:2016/2/19 6:59:00
--  
e.DataRow("汇总金额")=DataTables("明细表").SQLCompute("sum(借方金额)",“交易户名= \'" & e.DataRow("交易户名") & "\'   and 交易日期 >= #" & forms("统计汇总").controls("开始日期") & "# and 交易日期 <= #" & forms("统计汇总").controls("截止日期") & "#") 

e.DataRow("汇总金额")=DataTables("明细表").SQLCompute("sum(借方金额)",“交易户名= \'" & e.DataRow("交易户名") & "\'and     这个AND前加上空格试试!


--  作者:kaituozhe
--  发布时间:2016/2/19 8:48:00
--  

试了,不行


--  作者:blackzhu
--  发布时间:2016/2/19 8:55:00
--  
福星回答的两个问题都是犯错了:

e.DataRow("汇总金额")=DataTables("明细表").SQLCompute("sum(借方金额)",“交易户名= \'" & e.DataRow("交易户名") & "\'   and 交易日期 >= #" & forms("统计汇总").controls("开始日期").Value & "# and 交易日期 <= #" & forms("统计汇总").controls("截止日期").Value & "#") 

--  作者:Hyphen
--  发布时间:2016/2/19 8:55:00
--  
e.DataRow("汇总金额")=DataTables("明细表").SQLCompute("sum(借方金额)","交易户名= \'" & e.DataRow("交易户名") & "\' and 交易日期 >= #" & forms("统计汇总").controls("开始日期").value & "# and 交易日期 <= #" & forms("统计汇总").controls("截止日期").value & "#") 
--  作者:kaituozhe
--  发布时间:2016/2/19 10:15:00
--  

e.DataRow("汇总金额")=DataTables("明细表").SQLCompute("sum(借方金额)",filter & "交易户名= \'" & e.DataRow("交易户名") & "\'")

 

filter是定义的其他条件组合(包含交易日期及其他),上述格式对吗?

提示错误如下:

语法错误 (操作符丢失) 在查询表达式 \'交易日期 >= #2012-05-01# And 交易日期 <= #2012-11-30#交易户名= \'张三\'\' 中。


--  作者:大红袍
--  发布时间:2016/2/19 10:16:00
--  
e.DataRow("汇总金额")=DataTables("明细表").SQLCompute("sum(借方金额)", iif(filter>"", filter, "1=1") & " and 交易户名= \'" & e.DataRow("交易户名") & "\'")