cn.open "........." rs.open "select min(办单号) as aa, 颜色 , sum(数量) as bb from (select * from design_zs_color where 办单号='dfg' union all select * from design_bj_color where 办单号='dfg') as UnionTbl group by 颜色",cn,1,3 do whiule not rs.eof msgbox rs(0) rs.movenext loop rs.close cn.close set rs=nothing set cn=nothing
检查bof和eof,if not bof then movefirst 还有估计和CursorLocation有关
'使recordcount>0
.CursorLocation = adUseClient
.CursorType = adOpenStatic
'可以修改和保存
.LockType = adLockOptimistic
End With
rs.CursorLocation = adUseClient
rs.open sql,conn,adOpenKeySet,adLockOptimistic,adCmdText
rs.open "select min(办单号) as aa, 颜色 , sum(数量) as bb from (select * from design_zs_color where 办单号='dfg' union all select * from design_bj_color where 办单号='dfg') as UnionTbl group by 颜色",cn,1,3
do whiule not rs.eof
msgbox rs(0)
rs.movenext
loop
rs.close
cn.close
set rs=nothing
set cn=nothing
还有估计和CursorLocation有关