Solved

DSum calculation on main form from a subform DLookup field.

Posted on 2008-06-23
6
697 Views
Last Modified: 2013-11-25
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?

Thanks,

Ryan
0
Comment
Question by:jdol2949
  • 5
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 21848395
see this link

How to Bring a Subtotal from a Subform to a Main Form
http://support.microsoft.com/?kbid=208998
0
 

Author Comment

by:jdol2949
ID: 21848942
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):

=Sum([tbxViewPrice])
 

Main form control (tbxTotal):

=sfmViewParts.frmBOMViewParts!tbxSubTotal
 

Price lookup text box (tbxViewPrice):

=IIf(IsNull([ItemNmbr]),"",DLookUp("Price","Item","ItemNmbr = '" & [ItemNmbr] & "'"))

Open in new window

0
 

Author Comment

by:jdol2949
ID: 21849143
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?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:jdol2949
ID: 21849729
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)
Thanks.
0
 

Author Comment

by:jdol2949
ID: 21856218
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.

0
 

Accepted Solution

by:
jdol2949 earned 0 total points
ID: 21856425
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:
=sfmViewParts!tbxSubtotal

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.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now