small code in need of review

viperstingray

Registered User.
Local time
Today, 09:20
Joined
May 31, 2005
Messages
87
hi. I am trying to write a code to sum the total cost of all jobs that are selected as 'yes' in a combo box.

Once the user selects 'yes' in a combo box, they enter in a cost for that specific job. Each client may have 10s of jobs. I need to write a code that will sum up all the 'yes' selected jobs for a client. I know it should be an 'if' statement but I can't seem to get it to work. I need this value for a report. How would I do this and where would i put the code.

Help is appreciated.

Here is the code that I was thinking of, I don't think its right but it might be a start.


Dim Count As Variant
Dim CountImplementedTotal As Variant

CountCost = 0
CountImplementedTotal = 0


Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordSet("ECM Details")
Do While Not rst.EOF
If rst![AUDIT ID] = Forms![audit info]![AUDIT ID] Then
If rst![Has Measure been Selected] = "YES" Then
Count = Count + rst![Total Measure Cost]
End If
End If
rst.MoveNext
Loop

Text47.Text = Count
 
Why don't you use a query? Or, since you are writing a report, why not do the calculations in the report?
 
that is what I am trying to do. I just can't get it to add the totals of the implemented measures. Any ideas
 
Please just post one question on the topic under one forum, I've just answered this in Reports
 

Users who are viewing this thread

Back
Top Bottom