Subtotal formula in Subform (1 Viewer)

Tophan

Registered User.
Local time
Yesterday, 19:08
Joined
Mar 27, 2011
Messages
367
Hi,

I have an invoice form in which there are 3 categories of works - time based, task based and other.

For task based, there is a Dlookup formula that looks up the program used and applies a rate to the work. The problem I am having is subtotalling the tasks in the forms footer, so I can see a running total in the main form.

Below is the formula i first tried

Code:
=sum(DLookUp("[Rate]","tblPrograms","PrgmID=" & [PrgmID]*[Qty]))

That just result was blank.

So then I tried I tried this
Code:
=Sum(IIf([CategoryID]=1,0,DLookUp("[Rate]","tblPrograms","PrgmID=" & [PrgmID]*[Qty])))


All I'm getting is a zero result.
Note CategoryID #1 is Time based; #2 is task; and #3 is Other

Any help in fixing this formula would be greatly appreciated.
 

Ranman256

Well-known member
Local time
Yesterday, 19:08
Joined
Apr 9, 2015
Messages
4,339
in the subform footer, add a field with the formula:
=Sum(field)
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:08
Joined
Oct 29, 2018
Messages
21,454
Hi. Try looking up the rate first before multiplying it with the quantity. Right now, your formula is multiplying the quantity with the ID, so it’s not resulting in finding a rate.
 

Tophan

Registered User.
Local time
Yesterday, 19:08
Joined
Mar 27, 2011
Messages
367
Thank you. That worked. Changed the formula to the below and now everything is summing correctly

Code:
=Sum(DLookUp("[Rate]","tblPrograms","PrgmID=" & [PrgmID])*[Qty])

Thank you very much :)
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:08
Joined
Oct 29, 2018
Messages
21,454
Thank you. That worked. Changed the formula to the below and now everything is summing correctly

Code:
=Sum(DLookUp("[Rate]","tblPrograms","PrgmID=" & [PrgmID])*[Qty])

Thank you very much :)

Congratulations! Glad to hear you got it to work. Good luck with your project.
 

Users who are viewing this thread

Top Bottom