Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RUNNING TOTAL

Status
Not open for further replies.

Angelique

Technical User
Mar 9, 2001
127
AU
I need to present a running monthly total on a form. I was able to produce a running total using DLookup for a yearly total. The field is Forms!FormName.[Cost of Training]

I haven't used DLookup much so any help would be appreciated.

Angelique
 
Not sure if by Monthly total you mean 1) a total for every month... or 2) a total displayed for the current month.

If you goal is to have a field that displays the current month, I was able to come up with this:

Private Sub Form_Current()

TheField = DSum("AmountField", "MyTable", "MyDate Like Left(Date(),2) & '*'")
' all of the above is one line.

End Sub

Where you would create a text field (unbound) and code the above. This will calc the sum for the current month.

2) If you were looking for the monthly total for every month all year long. Then you would have twelve unbound text fields and would code simularly:

Private Sub Form_Current()

txtMonthlyTotalJan = DSum("MyAmount", "DateAmount", "Month(MyDate) = 1")
'all of the above is one line.

End Sub

The part that says (MyDate) = 1 be for January, (MyDate) = 2 would be for February and so on. ljprodev@yahoo.com
Professional Development
MS Access Applications
 
ljprodev,

That's exactly what I meant, sorry I didn't explain myself very well. Will put your example to work!

Angelique
 
Having problems with the MyDate! Call me thick or something but what is the variable MyDate because I am getting object errors when I run the code.

Thanks in advanced


Angelique
 
txtMonthlyTotalJan = DSum("MyAmount", "DateAmount", "Month(MyDate) = 1")
'all of the above is one line.


If you are talking about example #2, let me do a better job of explaining my varibles. Sorry for that.

"MyAmount" is the amount field in your table that we will be doing the sum on.

"DateAmount" is the name of MY table that holds the fields in question. (I should have explained that.

txtMonthlyTotalJan is one of the names of the twelve text boxes (name them as you like.)

The word Month is actually the name of a funtion.

Hope this makes it clearer. If not give me your field and table names and I will create the expression/example using your structure. B-)
MyDate is the date field in your table that determine the monthly grouping.

ljprodev@yahoo.com
Professional Development
MS Access Applications
 
Now that you have explained the variables, no problems!

Thanks


Angelique
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top