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
Puzzling situation, JayF. Set the Control Source of the sfrmTotal Text Box in the Sub-Form Footer to: - =DSum("[Quantity]","eqryPODetailsExtended","[Purchase ID] = " & [Forms]![dfrmPODetails]![sfrmcOrderDetails].[Form]![Purchase ID])
13 4835
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: - =Sum(Nz(([Quantity] * [Price])-(1- [Discount]),0))
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))
In case it is pertinent, here is the SQL for the SubForm's underlying query: - 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
-
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: - 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
-
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];
Is it possible for you to Attach a 'Sanitized' Version of your DB stripped of any Personal Info?
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.
Sure enough, decompiling the version I've just sent you fixed the Keep1Open problem, but not the #Error.
@JayF:
We'll look at the DB as see what we can do. BTW, what Version of Access are you using?
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.
@JayF:
I never saw the Attachment.
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.
Puzzling situation, JayF. Set the Control Source of the sfrmTotal Text Box in the Sub-Form Footer to: - =DSum("[Quantity]","eqryPODetailsExtended","[Purchase ID] = " & [Forms]![dfrmPODetails]![sfrmcOrderDetails].[Form]![Purchase ID])
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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 :...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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: 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...
|
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,...
|
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,...
|
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...
|
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...
|
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...
| |