DSum calculation on main form from a subform DLookup field.

Access 2003-
What I'm trying to do here is create a sum calculation that would total up all of the prices from the 'Price' field in the subform.  The only problem is, the prices on the sub form are currently being populated using the DLookup statement.  So, when a part is entered into the subform, the corresponding price is 'looked up' and displayed in a text box next to the part number.  What I want to do is have a text box on the main form (frmTestView) calculate all of these DLookup prices that appear on the sub form.  What would be the best way to go about calculating the Price field in this sub form?


Who is Participating?
jdol2949Connect With a Mentor Author Commented:
meh.. I think I got it again.
I moved a text box(tbxSubtotal) to the sub form footer and gave it this control source:
=Sum(DLookUp("Price","Item","ItemNmbr = '" & [ItemNmbr] & "'")*[ItemQty])

Then, I just simply referenced the above text box to the text box on the main form that displays the total:

Voila!  I now have a continuous subform that displays the prices of the selected items automatically, and once those prices are shown, then the quantities and DLookup prices are multiplied in the form footer, then displayed as a Total on the Main page.  Sweeeeet.
Rey Obrero (Capricorn1)Commented:
see this link

How to Bring a Subtotal from a Subform to a Main Form
jdol2949Author Commented:
Thanks cap, I followed all of the instructions from that link.  I'm still getting a '#Name?' error for the total on my main form.  I'm sure it has to do with the fact that the price is being referenced from a server database, and the rest of the subform is actually grabbing information from a local Access table.  Is there some sort of command to calculate the sum of the text box that generates the price for each item?  below are the two text box controls, and the text box that includes the DLookup statement.
subform txt box control (tbxSubTotal):
Main form control (tbxTotal):
Price lookup text box (tbxViewPrice):
=IIf(IsNull([ItemNmbr]),"",DLookUp("Price","Item","ItemNmbr = '" & [ItemNmbr] & "'"))

Open in new window

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

jdol2949Author Commented:
Or, is there a command that calculates the tbxViewPrice column from the subform AFTER the list has been populated by the two combo boxes on the main form?
jdol2949Author Commented:
or... is there some sort of OnClick or AfterUpdate event I can set somewhere to display the total after all of the subform fields have been populated?  The 'Price' column still wouldn't have a field name, but maybe I could reference the text box it's tied into? (tbxViewPrice)
jdol2949Author Commented:
Any comments or suggestions?   Can DLookup statements be referenced as a field name, so that I can calculate the sum of all of the prices that are on my continuous form?  Please.. any help at all would be greatly appreciated.

All Courses

From novice to tech pro — start learning today.