Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DSum calculation on main form from a subform DLookup field.

Posted on 2008-06-23
6
Medium Priority
?
729 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

824 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