Solved

DSum calculation on main form from a subform DLookup field.

Posted on 2008-06-23
6
700 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

776 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