I have created a project where I created a form (scm.frm). In this form I put a caption (label9). This caption will show the total amount in a database field. It is working properly, example if I want to know the total transaction in November month, it is showing properly. If this month has transaction NIL, it also shows. But when I want to see the transacton NIL month before I saw a total amount transacted month, it doesn't change the value in the form.
More specifically, I have database named A, its fields are Month, Year, Amount.
November month Total Amount=10000
December " =20000
January " =00000
I select November month with 2007 yr, it is showing 10000. Again I select December 2007, it is showing 20000, properly. But if I select January 2007, it is showing 20000 (the previous data).
I am giving you code...
I have declared in module...
Global con as new ADODB.connectio n
General declaration------
[CODE=vb]Dim data1 As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim subs As String
Dim subs1 As String[/CODE]
clik a command button()
[CODE=vb]On Error Resume Next
data1.ActiveCon nection = con
data1.CommandTe xt = "select sum(amunt) from amn where mon & yr & schm='" & (Combo1.Text) & "' & '" & (Text1.Text) & "''"
rs.Open data1, , adOpenDynamic, adLockReadOnly
If Not rs.EOF Then
subs = rs.Fields(0) /data field
subs = rs.Fields(1) / ''
subs = rs.Fields(2)
subs = rs.Fields(3)
Label9.Caption = subs
End If
rs.Close[/CODE]
Please help me.
More specifically, I have database named A, its fields are Month, Year, Amount.
November month Total Amount=10000
December " =20000
January " =00000
I select November month with 2007 yr, it is showing 10000. Again I select December 2007, it is showing 20000, properly. But if I select January 2007, it is showing 20000 (the previous data).
I am giving you code...
I have declared in module...
Global con as new ADODB.connectio n
General declaration------
[CODE=vb]Dim data1 As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim subs As String
Dim subs1 As String[/CODE]
clik a command button()
[CODE=vb]On Error Resume Next
data1.ActiveCon nection = con
data1.CommandTe xt = "select sum(amunt) from amn where mon & yr & schm='" & (Combo1.Text) & "' & '" & (Text1.Text) & "''"
rs.Open data1, , adOpenDynamic, adLockReadOnly
If Not rs.EOF Then
subs = rs.Fields(0) /data field
subs = rs.Fields(1) / ''
subs = rs.Fields(2)
subs = rs.Fields(3)
Label9.Caption = subs
End If
rs.Close[/CODE]
Please help me.
Comment