how to add numbers which is present in database on date basis in vb6.0 using adodc
Add numbers which are present in db
Collapse
X
-
Did you mean Sum of Numbers, which Belong to that particular date.Originally posted by rekhaschow to add numbers which is present in database on date basis in vb6.0 using adodc
eg, Sum of numbers for the date of July 05, 2007
and another sum for the date july 06, 2007 so on and so fort?Comment
-
i want to add numbers(amounts ) of seven days,month and so on.......date should automatically updated....... i want code for both..........Originally posted by jrtoxDid you mean Sum of Numbers, which Belong to that particular date.
eg, Sum of numbers for the date of July 05, 2007
and another sum for the date july 06, 2007 so on and so fort?Comment
-
Originally posted by QVeen72Hi,
Use this Query :
[code=vb]
sSQL = "Select Sum(Amt) From MyTable Where MyDate Is Between #" & txtFromDate.Tex t & "# And #" & txtToDate.Text & "# "
[/code]
REgards
Veena
Private Sub cmdshow_Click()
sSQL = "Select Sum(Amount) From xdetails Where MyDate Is Between #" & txtFromDate.Tex t & "# And #" & txtToDate.Text & "# "
txtTotal.Text = Val(sSQL)
End Sub
but its not adding the amount,........
mydatabase contains two fields, one is date and another one is amount, when i enter 2 dates it should show the sum of amounts which is in database b/w these dates. ( in database i have given the date format as medium date)Comment
-
Originally posted by QVeen72Hi,
thers is no IS in the query :
sSQL = "Select Sum(Amt) From MyTable Where MyDate Between #" & txtFromDate.Tex t & "# And #" & txtToDate.Text & "#
Yes, u can use ComboBox :
CDate(Combo1.Te xt)
Regards
Veena
Dim sSQL As String
Private Sub cmdTotal_Click( )
sSQL = "Select Sum(Amount) From Table1 Where date Between #" & txtFromDate.Tex t & "# And #" & txtToDate.Text & "# "
txtTotal.Text = Val(sSQL)
End Sub
its not adding the amount......... .
when i click the total cmd its coming 0Comment
-
Hi,
you have to open a recordset, just by giving Val() will not work..
what i have given is just a Query.
To open a record set, just go through this thread
Regards
VeenaComment
-
Originally posted by QVeen72Hi,
you have to open a recordset, just by giving Val() will not work..
what i have given is just a Query.
To open a record set, just go through this thread
Regards
Veena
Dim sSQL As String
Private Sub cmdAdd_Click()
Adodc1.Recordse t.AddNew
Text1.SetFocus
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdTotal_Click( )
sSQL = "Select Sum(Amount) From Table1 Where date Between #" & txtFromDate.Tex t & "# And #" & txtToDate.Text & "# "
txtTotal.Text = Val(sSQL)
End SubComment
-
Hi,
Declare a Connection object, Recordset Object :
[code=vb]
Dim sSQL As String
Dim AConn As New ADODB.Connectio n
Dim RST As New ADODB.Recordset
With AConn
.ConnectionStri ng = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=C:\MyDb. mdb"
.Open
End With
sSQL = "Select Sum(Amount) From Table1 Where date Between #" & txtFromDate.Tex t & "# And #" & txtToDate.Text & "# "
RST.Open sSQL, AConn
If Not RST.EOF Then
txtTotal.Text = RST(0) & ""
End If
RST.Close
[/code]
Replace C:\MyDb.mdb, to ur actual database path
REgards
VeenaComment
-
Originally posted by QVeen72Hi,
Declare a Connection object, Recordset Object :
[code=vb]
Dim sSQL As String
Dim AConn As New ADODB.Connectio n
Dim RST As New ADODB.Recordset
With AConn
.ConnectionStri ng = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=C:\MyDb. mdb"
.Open
End With
sSQL = "Select Sum(Amount) From Table1 Where date Between #" & txtFromDate.Tex t & "# And #" & txtToDate.Text & "# "
RST.Open sSQL, AConn
If Not RST.EOF Then
txtTotal.Text = RST(0) & ""
End If
RST.Close
[/code]
Replace C:\MyDb.mdb, to ur actual database path
REgards
Veena
thank you.....
thanks a lot..........
it helps me a lot........ i am d beginner of vb...... i want to learn more about vb..... thats y i m doing small pgms......... thank u for your cooperationComment
Comment