When I run 2 sql queries and return the result to flexgrid , I can only see data from the 2ns query and not the first,plz helpVB Code:
sql = "select count(*) as orders, date as jdate from data where date between ' " & Format(Form1.dtp1.Value, "mm-dd-yyyy") & " ' and ' " & Format(Form1.dtp2.Value, "mm-dd-yyyy") & " ' detail = 'order' group by date" rs1.Open sql, gcn, adOpenStatic, adLockOptimistic If rs1.RecordCount <> 0 Then rs1.MoveFirst Do While Not rs1.EOF sql1 = "insert into tmp(col1,col2) values (" & rs1("jdate") & "," & rs1("orders") & ")" rs2.Open sql1, con, adOpenDynamic, adLockOptimistic rs1.MoveNext Loop End If sql2 = "select count(*) as torders, date as jdate from data where date between ' " & Format(Form1.dtp1.Value, "mm-dd-yyyy") & " ' and ' " & Format(Form1.dtp2.Value, "mm-dd-yyyy") & " ' group by calldate" rs3.Open sql2, gcn, adOpenStatic, adLockBatchOptimistic If rs3.RecordCount <> 0 Then rs3.MoveFirst Do While Not rs3.EOF sql3 = "insert into tmp(col3) values (" & rs3("torders") & ")" rs4.Open sql3, con, adOpenDynamic, adLockOptimistic rs3.MoveNext Loop End If rs2.Open "select * from tmp", con, adOpenStatic, adLockOptimistic Set MSHFlexGrid1.DataSource = rs2
Edit: Added [vbcode][/vbcode] tags for clairty. - Hack




Reply With Quote