473,398 Members | 2,404 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,398 software developers and data experts.

#Error on SubForm field totalling.

45
Hi all,

I'm stumped and it hurts to have to give up and ask for help, but even the omniscient Google limited by my mere biology can't solve this, and I'm still learning Access so here goes.

I have a main form containing a subform, which lists products within an order, in the footer of which is a text box called sfrmTotal whose control source contains the expression:
=Sum(Nz([SubTotal],0))

Back on the main form I have a text box with control source:
=[sfrmcOrderDetails].[Form]![sfrmTotal]

The subform also contains fields such as Discount, Tax, Quantity, etc. I have tried the above Sum() expression on all of the fields and every single one of them returns #Error on both the subform control and the main form one.

[Total] and [SubTotal] are calculated query fields, but [Quantity] and [Discount] are not. Should that even make a difference?

I have tried a function called nnz (not numeric zero), which makes no difference.

I was tweaking queries, checking names and messing with things for the best part of yesterday. I've learned a lot on the way, but I'm no closer to figuring out what is causing the #Error on ALL of the fields.

My last resort is to appeal to the Gurus of Bytes.com for divine assistance or at least guide me in the right direction of where I should be looking for a solution to banish the #Errors from my project.


Thanks in advance.

Jay
Feb 11 '12 #1

✓ answered by ADezii

Puzzling situation, JayF. Set the Control Source of the sfrmTotal Text Box in the Sub-Form Footer to:
Expand|Select|Wrap|Line Numbers
  1. =DSum("[Quantity]","eqryPODetailsExtended","[Purchase ID] = " & [Forms]![dfrmPODetails]![sfrmcOrderDetails].[Form]![Purchase ID])

13 4835
ADezii
8,834 Expert 8TB
I think the problem is that you are trying to Summarize a Calculated Field. You would need to include the entire Expression within the Sum() Function, something similar to:
Expand|Select|Wrap|Line Numbers
  1. =Sum(Nz(([Quantity] * [Price])-(1- [Discount]),0))
Feb 11 '12 #2
JayF
45
Thanks for your speedy reply ADezii, but the expression won't even work when trying to sum [Quantity], [Unit Cost] or similar non-calculated fields, e.g.:

=Sum(Nz([Quantity],0))
Feb 11 '12 #3
JayF
45
In case it is pertinent, here is the SQL for the SubForm's underlying query:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblPODetails.*, tblPO.[Order Date], tblPO.[Paid Date], tblPO.[Supplier ID], eqryContactsExtended.Company, eqryContactsExtended.[Contact Name], (([Quantity]*[Unit Cost])-(([Quantity]*[Unit Cost])/100)*[Discount]) AS SubTotal, (([SubTotal]/100)*Nz([Tax Rate],0)) AS Tax, [SubTotal]+[Tax] AS Total
  2. FROM (tblPODetails LEFT JOIN tblPO ON tblPODetails.[Purchase ID] = tblPO.[Purchase ID]) LEFT JOIN eqryContactsExtended ON tblPO.[Supplier ID] = eqryContactsExtended.[Contact ID];

And the main forms's underlying query:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblPO.*, tblPaymentMethods.[Payment Method], eqryContactsExtended.[Contact Name], eqryContactsExtended.Company, eqryContactsExtended.[E-mail Address], eqryContactsExtended.CIF, eqryContactsExtended.[Address 1], eqryContactsExtended.[Address 2], eqryContactsExtended.City, eqryContactsExtended.County, eqryContactsExtended.[Country/Region], eqryContactsExtended.[Post Code], tblPOStatus.Status
  2. FROM ((tblPO LEFT JOIN eqryContactsExtended ON tblPO.[Supplier ID] = eqryContactsExtended.[Contact ID]) LEFT JOIN tblPaymentMethods ON tblPO.[Payment Method ID] = tblPaymentMethods.[Payment Method ID]) LEFT JOIN tblPOStatus ON tblPO.[Purchase Status ID] = tblPOStatus.[Status ID];
Feb 11 '12 #4
ADezii
8,834 Expert 8TB
Is it possible for you to Attach a 'Sanitized' Version of your DB stripped of any Personal Info?
Feb 11 '12 #5
JayF
45
Sure, I appreciate your taking the time to look at it.

The passwords for both FE and BE are asdf and you'll need to hold shift for the FE. It's full of dummy data, nothing sensitive.

The form I'm trying to get this working on is dfrmPODetails. As of preparing this database to upload, this form seems to be having a problem with the Keep1Open function in mdKeep1Open (I've not been anywhere near it). Could corruption be causing this behaviour and the #Error? I had the old GoSub problem a few versions back and had to /decompile it.

Again, thank you very much for your help on this. You and the other guys on this site are amazing.
Feb 11 '12 #6
JayF
45
Sure enough, decompiling the version I've just sent you fixed the Keep1Open problem, but not the #Error.
Feb 11 '12 #7
ADezii
8,834 Expert 8TB
@JayF:
We'll look at the DB as see what we can do.

BTW, what Version of Access are you using?
Feb 11 '12 #8
JayF
45
Thanks. 2007.

I take it you managed to download it before I took it down? It's fine if you did, it just has my email addresses in the Dummy Data. I didn't want to leave it there forever as a spam precaution. I'll upload a new copy soon.

I'm in the process of rebuilding the queries and having a play with some other things, tweaking yet more things as I go. Nothing I do seems to change that #Error though.
Feb 11 '12 #9
ADezii
8,834 Expert 8TB
@JayF:
I never saw the Attachment.
Feb 11 '12 #10
JayF
45
Check back in 5 minutes.
Feb 11 '12 #11
JayF
45
Ok. Uploaded again with some things changed.

The forms I'm banging my head against are dfrmOrderDetails and the confusingly named xsfrmOrderDetails (still playing with things), and dfrmPODetails and sfrmPODetails.

Password to the backend is asdf. Hold shift to open the front end menus.

Thanks again.
Feb 11 '12 #12
ADezii
8,834 Expert 8TB
Puzzling situation, JayF. Set the Control Source of the sfrmTotal Text Box in the Sub-Form Footer to:
Expand|Select|Wrap|Line Numbers
  1. =DSum("[Quantity]","eqryPODetailsExtended","[Purchase ID] = " & [Forms]![dfrmPODetails]![sfrmcOrderDetails].[Form]![Purchase ID])
Feb 12 '12 #13
JayF
45
I'm glad it is not just me that it was puzzling.

With this and the problem it was having with the Keep1Open function (which a /decompile fixed) I figured it could be corruption, so I moved everything over to a new shell, bit by bit, dropping some redundant objects. It still didn't work, at which point I decided to rebuild the subforms using the form wizard.

This solved the problem. Wizards work in mysterious ways.

The expression you conjured up also did the trick on the clean version, and gave me a new tool in my slowly growing box of tools. So thank you for that.

This is my first attempt at a project so any other feedback points you might have spotted while you were digging around would be more than welcome.

Jay
Feb 12 '12 #14

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

Similar topics

0
by: DotNetJunkies User | last post by:
I have to deserialize an XML document to objects and then serialize it back to XML to pass to the stored proc. I am attaching partial code. After this , I also have to serialize Here is the XML :...
2
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text box that references a field on the subform. What I'd like it to do is show the value...
1
by: perryche | last post by:
Experts, I have a form with 2 subforms (a & b). I am trying to bring a values from the subforms into the main form (say subtotal) and add the two subtotals up in the main form and display a Grand...
2
by: Gary T. | last post by:
I have a subform (that is linked to a table) in a blank form. When the table is viewed in its subform state in the form, the headings are not user friendly. ie. CustN I would want it to read in...
1
by: Stephen D Cook | last post by:
I have a search form with a query-linked subform. One of the fields in the subform are date fields. Is there a way to autopopulate the DateFilled field when the person enters the field? I need...
7
by: heinemans | last post by:
Hi there, main form name = reserveringen subform name = subform reserveringen main form fields are: datetot, datevan, fietscode. Subform fields are: dateuit, datemin, fietsid Now i want to...
1
by: MLH | last post by:
If the RecordSource for subform SF on main form MF is a query and I change one of the field values in the subform control from 75 to say - 13 and click on another record, the value in the...
5
by: z.ghulam | last post by:
Hi, I have a subform in a main form. When I create new records in the subform I would like the Subform. to autofill with the MainForm. It sounds quite simple, but ive been bustin my brains...
5
by: opmandrake | last post by:
Evening guys. Here something that's been driving me nuts for the past couple of hours. I have a mainform and in it, two subforms. Normally I'd like the fields to be read-only, but if a user has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.