473,790 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with calculated control in subform footer

2 New Member
I have the calculation located in the footer of the subform.
There is sometimes no rows in this form so I have used Allen Browne's IIF(FormHasData ([form]),calculation,0 ) syntax to show a zero if there aren't any rows to calculate on.

Consequently I copied his public function

Expand|Select|Wrap|Line Numbers
  1. Public Function FormHasData(frm As Form) As Boolean
  2. 'Purpose: Return True if the form has any records (other than new one).
  3. ' Return False for unbound forms, and forms with no records.
  4. 'Note: Avoids the bug in Access 2007 where text boxes cannot use:
  5. ' [Forms].[Form1].[Recordset].[RecordCount]
  6. On Error Resume Next 'To handle unbound forms.
  7. FormHasData = (frm.Recordset.RecordCount <> 0&)
  8. End Function
  9.  
  10. 'Notes
  11.  
  12. ' 1. Leave the [Form] part of the expression as it is (i.e. do not substitute the name of your form.)
  13. ' 2. For Access 97 or earlier, use RecordsetClone instead of Recordset in the function.
  14. ' 3. A form with no records still has display problems. The workaround may not display the zero, but it should suppress the #Error.


Other relevant function (for calculating extended price):

CODE
Expand|Select|Wrap|Line Numbers
  1. Public Function CalcExtension(ByVal Quantity as integer, ByVal Price As Currency, ByVal DiscountPercent As Integer) As Currency
  2.  
  3. Dim Extension as Currency
  4. Dim Discount as Double
  5.  
  6. Extension = Quantity * Price
  7. Discount = DiscountPercent / 100
  8. CalcExtension = Extension - (Extension * Discount)
  9.  
  10. End Function


Form is bound: tblOrderDetails

Two calculations:

First: summing the quantities
Control Name: txtqty
Control Source: tblOrderDetails .qty (long integer)

Attempted: =IIF(FormHasDat a([form]), sum([qty]),0)
Result: 0 when no records, #error when there ARE records


Second: summing the extended price
Control Name: txtExtension (but it is calculated using a function so I have put in the calculation rather than the control)
Involved Controls: txtqty (tblOrderDetail s.qty -- long integer); txtDetailsPrice (tblOrderDetail s.Price -- Currency); txtDiscount (tblorderDetail s.DiscountAmnt -- long integer)

Attempted: =IIF(FormHasDat a([Form]),Sum(CalcExten sion(nz([txtQty],0),Nz([txtDetailsPrice],0
),nz([txtDiscount],0))),0)
Result: 0 when no records, #error when there ARE records
Note: =CalcExtension( nz([txtQty],0),Nz([txtDetailsPrice],0),nz([txtDiscount],0)) is working well in my txtExtension control

I did try opening the subform outside of the parent/child relationship so it would have records (just chose sfrmOrderDetail s from the Object List) and tried the straight ahead =sum([qty]) and I got the #error message.

I just don't get it. This database has been compiled and compacted and repaired repetitively.

Why oh why???
Dec 14 '10 #1
1 2904
lvmoore
2 New Member
I've discovered (by messing around with this subform outside of the master form) that the =sum([Qty]) works great as long as the other one is absent --> which tells me that the problem is in the other (sum(calcextens ion)) one. Can you please look at that syntax and tell me if you notice anything glaring?

Thanks
Dec 15 '10 #2

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

Similar topics

2
1814
by: Tony Williams | last post by:
I have a form with a tabcontrol which has a number of pages. I want to check the value of a calculated control on one page with a calculated control on another page. The calculated control (txtTotNbrClients) on page 3 is the sum of these controls on that page ( + + + + + + + ) The calculated control on page 4 (txtClientsTot) is the sum of these controls on that page ( + + + +
6
5884
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 entries) I can't seem to get the calculated control on main form to do what I want...... Is this possible, if so, how? Help!
3
4437
by: mahsa | last post by:
Hi,How can I access to checkbox control in footer template of datalist and fire the selectedchangeindex event? -- Regards mahsa
0
1074
by: 00_ChInkPoIntD12 | last post by:
Is there any box wrapping control? so that I can put stuff in the box so that it looks more professional in a page. I am not sure what they call. It seems stupid to me to use "Header" and "Footer" (User Control) like this.. <c1:HEADER id="BoxHeader" runat="server"></c1:HEADER> ...Form, HTML Content or another control...
2
5545
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by Form" in order to search for records based on this form, I would like to be able to enter a value in this "days" control so that I can filter records on the form based on this calculated interval (i.e., i want to search for records specifically where...
2
3083
by: PrimeHawk | last post by:
I am attempting to add a calculated control that counts the number of records displayed in a subform. I have two seprate tabs, hopefully it will not change the value if I switch between the tabs. I have tried the following codes to no avail: =MemberInformationSubform.Form!txtFirstNameCount and Count* Hoping that it would count the first name field entries that I have entered.
17
18370
by: MariaTorvalds | last post by:
I have a problem where if I use a calculated control, for example =Date()) on my form, PLUS I have a subform on a tab control on the same form, then when I refresh the record (by menu command or VBA me.refresh), the DB crashes! I've stripped the thing right down, and tested with a) no calculated control - no problem, b) no subform - no problem. c) moving the subform off the tab control to a free space on the underlying form - again, the...
2
4131
by: csolomon | last post by:
Hello: I would like to use information on one form to populate another form. There are 2 controls I would like to transfer; a list box control and a text box control. both are unbound controls in the subform footer of the form F_MixDesign. Form1: F_MixDesign Subform1: SF_MixSample Control name: txtWaterReqWt Form2:FSampleRequest Subform2: SF_SampleRequest Control name: txtWater
3
4903
wordbrew
by: wordbrew | last post by:
Hello all, I searched the forums as much as I can and haven't found a viable solution. I have a subform that filters the records by Publisher. In the subform I have a calculated control called "% of Track Commission", that takes the subform control "# of Writers" and divides it by the subform control "# of Writers for Track". From this I have another control called "TotalTrackCommission" that then takes "% of Track commission" and...
29
2942
by: Bigdaddrock | last post by:
I have tried using the SetValue Macro to assign the value of a calculated control to another BOUND Control on the same form but have not been successful. I followed the exact format shown in MS Access help instructions. The amount appears properly in the unbound text box (derived from data in a subform within the same form), however I cannot get that amount to then appear in a Bound Control's text box using the SetValue macro. I am only...
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9986
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.