473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Sum function in the footer of a continuous sub-form of an already calculated field in

Okay so, i have an order form in which i have embedded a continuous sub-form which has the product code price and description which is from a query of the products table. I also have a quantity box where the quantity of the product the customer wants to enter can be input. Next i have an unbound text box where i have used the calculation =[Text12]*[Quantity]. Text12 is the name of the text box where the price appears when the product code is entered. This calculation works perfectly. The trouble i am having is the sum function that i need in the footer to try and produce a total for the whole order after all of the products have been entered this is what i have: =Sum([Text14]) Text14 is the textbox where the sub-total calculation is done and i have also tried =Sum([Text12]*[Quantity]) tried all of which have gave me the same #error message when i run it. Any help would be very much appreciated as i am running out of option as to what the problem is. Thanks
Nov 8 '16 #1
1 782
jforbes
1,107 Expert 1GB
I don't think what you are trying will work. I haven't tried using a SUM() in a TextBox on a Form, just a Report, so I'm not 100% sure. But I wouldn't recommend that approach anyway. I've found it's easier to build either a Function or Query to return Totals and other calculations that will end up being in multiple places in your Application. This way if the formula changes there is only one place to make the change. It doesn't sound like much, but maybe your Total takes into account a base margin of 20%, then the owner decides to bump it up to 25%, or to make it change based on product line. Having only one place to make this change would make this modification much easier and less error prone.

Usually, for Totals I make one Query that performs all the LineItem calculations. Then I make a second Query, based on the previous Query that performs the Totals on Groups of LineItems, where the Group is determined by the PrimaryKey, like OrderNumber, InvoiceNumber, or QuoteNumber.

Once the Queries are made, they can be included as a link in a RecordSource or sometimes you can change the RecordSource over to the Totals Query and use the total values as Bound Fields. The caveat is that sometimes doing so will make the RecordSource ReadOnly.

Another option is to use Functions to retrieve values from the Query as needed. In your case, you could create a Function in which you pass the PrimaryKey of the MainForm's record and it would return the TotalValue from the Query that has all the Totals in it. Here is a basic example:
Expand|Select|Wrap|Line Numbers
  1. Public Function getOrderTotals(Byref lPrimaryKey As Long) As Currency
  2.     getOrderTotals= Dlookup("TotalValue", "TotalsQuery", "PrimaryKey=" & lPrimaryKey )
  3. End Function
There are a lot of other options and ways of doing this sort of thing, but this is the model that I try to use because you can then turn around and make as many Reports and Forms as people want, and the Totals always work the same.
Nov 9 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Allen Browne | last post by:
Subform is based on a single-table query that contains a calculated field: Amount: Round(CCur(Nz(*,0)),2) Continuous subform displays this field in a text box named Amount. As user enters new...
2
by: Norma | last post by:
I have a table with a UPC#, CasesCompleted, TotalHours, standardGoal (pieces per hour) I am generating a report that groups by UPC and figures out production goals. In the Detail section of each...
2
by: Simon P | last post by:
Hello group, I'm in desperate need of help. Here goes : I have the following tables : CONTACTS (ContactID, FirstName, LastName, Company, etc.), SHOWS (ShowID, ShowDescription) and SHOWDETAILS...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
0
by: Karl Roes | last post by:
I'm still having trouble posting follow-ups. :-( "Unable to retrieve message 7cc66112.0501041919.3a6628b4@posting.google.com" Now Turtle wrote "You'll need an extra field in the table...
3
by: jburris | last post by:
I have been through enough of these threads to think that this should be an easy fix... but, are there circumstances in which the following code syntax does not work? =!!.Form! (this is out of...
1
by: gavo | last post by:
Hello everyone! Using A2K i have a form(a) with a subform(b) and within the subform there is a continuous subform(c). in the subform (b) there is a command button used to call a public...
6
by: dhowell | last post by:
I have a "form" and "subform" where I would like a calculated control on the form which sums the values of a datasheet column of the subform. (datasheet on subform may have a variable number of...
1
by: Richard | last post by:
A shipment of material is received. The shipment contains several items. Each item is assigned an internal tracking number for auditing purposes and further processed. The tracking number is...
3
by: virtualgreek | last post by:
Dear all, I have a scenario that is driving me nuts. (MS Access 2003) I have a form/subform (Continuous form) where it gets its data from tables Order and Order_Details. In the footer...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.