virxen's Avatar, Join Date: Nov 2009
Pro contributor
query1
==============
Code:
SELECT DISTINCT date AS field1, sum([Total Amt]) AS field2
FROM Table1
GROUP BY date;
notice that field1,field2 are the labels of datagrid columns


query2
================
Code:
SELECT DISTINCT date AS field1, sum([Total Amt]) AS field2
FROM Table2
GROUP BY date;
change your queries and try again



p.s. you do not need second database(db27) change in form31 the properties of
adodc1 to use as database the db1.

Last edited by virxen; 24Aug2010 at 02:44..
shabbir, viv345 likes this
viv345's Avatar, Join Date: Feb 2010
Contributor
Sir Should I create two data grid in form 31.
virxen's Avatar, Join Date: Nov 2009
Pro contributor
it depends on what you are planning to do
viv345 like this
viv345's Avatar, Join Date: Feb 2010
Contributor
Sir,
I want both data grid total in one data grid. But by making two sql queries i have to create two data grids. How can calculate two grid query in one?
viv345's Avatar, Join Date: Feb 2010
Contributor
If following Code is written:-
Private Sub Command4_Click() 'GoBack button
Form1.Text1.Text = "i was sent by form27!!!"
Form1.Show
Form27.Hide
End Sub

How I can I get the Total value entered in All Grids
virxen's Avatar, Join Date: Nov 2009
Pro contributor
Quote:
Originally Posted by viv345 View Post
Sir,
I want both data grid total in one data grid. But by making two sql queries i have to create two data grids. How can calculate two grid query in one?
one of the many ways is this

Code:
Private Sub Command1_Click()
On Error Resume Next
conn.Execute "drop table table3"
conn.Execute "drop table table4"
conn.Execute "SELECT DISTINCT table2.Date AS dates, Sum(table2.[total amt]) AS sums INTO table3 From table2 GROUP BY table2.Date;"
conn.Execute "SELECT DISTINCT table1.Date AS dates, Sum(table1.[total amt]) AS sums INTO table4 From table1 GROUP BY table1.Date;"
conn.Execute "INSERT INTO table3 ( dates, sums ) SELECT dates, sums FROM table4;"
conn.Execute "drop table table4"
conn.Execute "SELECT DISTINCT table3.Dates AS dates, Sum(table3.sums) AS sums INTO table4 From table3 GROUP BY table3.Dates;"
conn.Ececute "drop table table3"
conn.Close
conn.Open
Form31.Show
Form2.Visible = False
End Sub
and in form31 change adodc1 properties(see picture)
Attached Images
File Type: jpg adodcproperties.jpg (31.2 KB, 2 views)
viv345 like this
viv345's Avatar, Join Date: Feb 2010
Contributor
Private Sub Command4_Click() 'GoBack button
Form1.Text1.Text = "i was sent by form27!!!"
Form1.Show
Form27.Hide
End Sub

If this code is written then how can i get the grand total of all the grids
viv345's Avatar, Join Date: Feb 2010
Contributor
I tried this code but the Table 4 is blank and not giving the results in Form 31.
virxen's Avatar, Join Date: Nov 2009
Pro contributor
Quote:
Originally Posted by viv345 View Post
I tried this code but the Table 4 is blank and not giving the results in Form 31.
you do something wrong check this
Attached Files
File Type: rar trial.rar (35.5 KB, 3 views)
shabbir like this
viv345's Avatar, Join Date: Feb 2010
Contributor
Private Sub Command4_Click()
Form1.Text1.Text = DataGrid1.Columns(9).Text
Form1.Show
Form27.Hide
End Sub

If this code is written then how can i get the grand total of all the grids