注册 登录
编程论坛 VB6论坛

求助 combox 改变后 datagrid 里的显示相应数据并计算及排序并去除为小于等于 0 的数据

xiang1434 发布于 2014-06-18 15:38, 619 次点击
在combox里输入内容后,在datagrid里显示相应内容。
问题:datagrid里的数据是由两个表组合查询得来。
下记单独查询是可以的,可combox与datagrid关联络就不会了。

下面这个代码可关联但不能计算加减及排序
Private Sub Combo1_click()
Adodc1.RecordSource = "select xhead.name,xslip.porder,xslip.vendor,xslip.kvol,xslip.tjitu,xslip.ddate from xhead inner join xslip on xhead.code=xslip.code where name='" & Combo1.Text & "'"
Adodc1.Refresh
End Sub

下记这个代码可以进行两列加减及排序并去除小于等于0的数据,但是combox值改变后datagrid不能关联改变。
Private Sub Combo2_click()
Adodc2.RecordSource = "select xhead.name as 品名,xslip.porder as 定单号,xslip.vendor as 供应商,xslip.ddate as 发注日期,xslip.kvol-xslip.tjitu as 注残 from xhead inner join xslip on xhead.code=xslip.code where xslip.kvol-xslip.tjitu>0 order by xslip.ddate asc" 'union select name from xhead where name='" & Combo2.Text & "'"
Adodc2.Refresh

请上手帮忙啊,搞了好久了都没搞出来。
6 回复
#2
xiang14342014-06-18 19:57
有没有高手指点下呀。
#3
w3609894262014-06-18 22:52
看不懂,详细解释下问题
#4
bczgvip2014-06-19 22:38
by xslip.ddate asc" 'union select name
中间标点是什么情况?话说没啦到后面看是否被注释么?
#5
alike1232014-06-20 12:52
同楼上问,你中间的标点应该把后面的代码注释了
#6
xiang14342014-06-21 13:05
因为代码在一起运行时提示“关键字‘union'附近有语法错误。所以把后面的语句注释了。
#7
xiang14342014-06-22 09:51
下面这样的语句对不对

Private Sub Combo2_click()
Adodc2.RecordSource = "select xhead.name as 品名,xslip.porder as 定单号,xslip.vendor as 供应商,xslip.ddate as 发注日期,xslip.kvol-xslip.tjitu as 注残 from xhead,xslip where xhead.code=xslip.code xslip.kvol-xslip.tjitu>0 and name='" & Combo2.Text & "' order by xslip.ddate asc"
1