473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Sum Of A Field In Vb6.0(problem In Coging)

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 to know the total transaction in November month,It is showing properly,if this month has transaction NIL,it also shows.
My problem is that, when I see the transaction of November,it shows exactly,but when I want to to see the other month (which month has nt transacted) its shows the previous data,ie November month..

Source code :
i have declaired in module......
Global con as new ADODB.connection

General declairation------
Dim data1 As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim subs As String
Dim subs1 As String

clik a command button()

On Error Resume Next
data1.ActiveConnection = con
data1.CommandText = "select sum(amunt) from amn where mon & yr & schm='" & (Combo1.Text) & "' & '" & (Text1.Text) & "'& '" & (Combo2.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

Plz help me....
Nov 16 '07 #1
3 2379
QVeen72
1,445 Expert 1GB
Hi,

Before checking for EOF, write this :

Label9.Caption = ""
If Not rs.EOF Then


Regards
Veena
Nov 16 '07 #2
On Error Resume Next
data1.ActiveConnection = con
data1.CommandText = "select sum(amunt) from amn where mon & yr & schm='" & (Combo1.Text) & "' & '" & (Text1.Text) & "'& '" & (Combo2.Text) & "'"
rs.Open data1, , adOpenDynamic, adLockReadOnly
Label9.Caption = ""
If Not rs.EOF Then
subs = rs.Fields(0)
subs = rs.Fields(1)
subs = rs.Fields(2)
subs = rs.Fields(3)
Label9.Caption = subs
End If
rs.Close

I have written this code but it is not working yet, When I see the total amount of transacted month,then on the same form If I want to see the total amount of other month(which month has no transaction),It is not showing NIL....Can I make it clear 2 u...
Plz help.
Nov 16 '07 #3
QVeen72
1,445 Expert 1GB
Hi,

First remove "On Error Resume Next " Statement, this will help you catch the error.
Moreover, you are not closing the Recordset, after End If, write
RS.Close
Set RS = Nothing

Hope it should fix up..

Regards
Veena
Nov 17 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mal | last post by:
I have an ACC 2000 database that has a strange behaviour I have a small table, with just a few fields... My report has very simple grouping and sorting, no code bar a NODATA event. I have a...
4
by: Deborah V. Gardner | last post by:
I have a multi-user database in Access 2000. The back end is on the server and the front end is on each machine. The user will go to a field (defined as data type Memo) and make some changes. Then...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
5
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
5
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each...
3
by: Roy | last post by:
Hi All, I have a table in A2K application.I get a memo field via download from a .csv file.The contents are as below: field name is TicketStatus, For example,a single ticket,TicketID 12345 ...
6
by: Steve67 | last post by:
Wonder if I can get someone’s help with a problem I am having on where to place an IF statement in VBE. I have created a form in Access 2003 that has an automatic calculated field. Basically you...
9
by: Brett_A | last post by:
I have a form where the first field is a dynamic drop-down that pulls from a db (Access). The fields associated with the query are task_id, task_name and task_rate. The field has the value of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.