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

Summing a number based on a text field

kcdoell
230 100+
Hello:

I have two fields on a table that is displayed on my continous form.

GWP = Number
Binding Percentage = Text (a value list of 25%, 50%, 90% & 100%)

I have a unbound text box that I placed in the footer and in the control source I wrote the following:

Expand|Select|Wrap|Line Numbers
  1. =Sum([GWP])
  2.  
This works but now I am trying to write this code to only sum the "GWP" where the value list of my binding percentage field is 50% or greater. I tried this:

Expand|Select|Wrap|Line Numbers
  1. =sum(iif((Binding_Percentage)=50%))
  2.  
but I keep on getting complile errors. I think because the value list is text.

Can anybody assist?

Thanks
Mar 25 '08 #1
18 2164
ADezii
8,834 Expert 8TB
Hello:

I have two fields on a table that is displayed on my continous form.

GWP = Number
Binding Percentage = Text (a value list of 25%, 50%, 90% & 100%)

I have a unbound text box that I placed in the footer and in the control source I wrote the following:

Expand|Select|Wrap|Line Numbers
  1. =Sum([GWP])
  2.  
This works but now I am trying to write this code to only sum the "GWP" where the value list of my binding percentage field is 50% or greater. I tried this:

Expand|Select|Wrap|Line Numbers
  1. =sum(iif((Binding_Percentage)=50%))
  2.  
but I keep on getting complile errors. I think because the value list is text.

Can anybody assist?

Thanks
Assuming your Table Name is Table1, and you are including 'ALL' the Records from Table1 in the Continuous Form:
Expand|Select|Wrap|Line Numbers
  1. =DSum("[GWP]","Table1","Val([Binding_Percentage]) >= 50")
Mar 25 '08 #2
kcdoell
230 100+
Assuming your Table Name is Table1, and you are including 'ALL' the Records from Table1 in the Continuous Form:
Expand|Select|Wrap|Line Numbers
  1. =DSum("[GWP]","Table1","Val([Binding_Percentage]) >= 50")

Actually my continous form's record source is driven by a query called "ReQryForecast" Will that make a difference ADezii?
Mar 25 '08 #3
kcdoell
230 100+
Actually my continous form's record source is driven by a query called "ReQryForecast" Will that make a difference ADezii?

Figured it out, Thanks!!
Expand|Select|Wrap|Line Numbers
  1. =DSum("[GWP]","ReQryForecast","Val([Binding_Percentage]) >= 50")
  2.  
Mar 25 '08 #4
kcdoell
230 100+
Thanks for all the help I was reading about the VAL method last night and will use it in the future.

Best regards,

Keith.
Mar 25 '08 #5
ADezii
8,834 Expert 8TB
Thanks for all the help I was reading about the VAL method last night and will use it in the future.

Best regards,

Keith.
You are quite welcome, Keith.
Mar 25 '08 #6
kcdoell
230 100+
You are quite welcome, Keith.

ADezii:

Hello again, I have one more situation regarding this subject. Currently I have the text box's control source, SumGWP, set to:

Expand|Select|Wrap|Line Numbers
  1. =DSum("[GWP]","ReQryForecast","Val([Binding_Percentage]) >= 75")
if "Binding_Percentage" is < 75 than my unbound text box "SumGWP" is blank even when I set its default value property to 0. I thought I would apply the Nz expression below:

Expand|Select|Wrap|Line Numbers
  1. =DSum(Nz([GWP],0),"ReQryForecast","Val([Binding_Percentage]) >= 75")
But that did not work either. How would I best approach this scenario so that it will populate a 0 instead of a blank if "Binding_Percentage" is < 75?

Thanks and hope all is well,

Best regards,

Keith.
Apr 29 '08 #7
ADezii
8,834 Expert 8TB
ADezii:

Hello again, I have one more situation regarding this subject. Currently I have the text box's control source, SumGWP, set to:

Expand|Select|Wrap|Line Numbers
  1. =DSum("[GWP]","ReQryForecast","Val([Binding_Percentage]) >= 75")
if "Binding_Percentage" is < 75 than my unbound text box "SumGWP" is blank even when I set its default value property to 0. I thought I would apply the Nz expression below:

Expand|Select|Wrap|Line Numbers
  1. =DSum(Nz([GWP],0),"ReQryForecast","Val([Binding_Percentage]) >= 75")
But that did not work either. How would I best approach this scenario so that it will populate a 0 instead of a blank if "Binding_Percentage" is < 75?

Thanks and hope all is well,

Best regards,

Keith.
Try:
Expand|Select|Wrap|Line Numbers
  1. =IIf(Val([Binding_Percentage]) < 75, 0, DSum([GWP], "ReQryForecast"))
Apr 29 '08 #8
kcdoell
230 100+
Your great, worked perfectly......

Thanks,

Keith.
Apr 29 '08 #9
ADezii
8,834 Expert 8TB
Your great, worked perfectly......

Thanks,

Keith.
You are quite welcome, Keith.
Apr 29 '08 #10
kcdoell
230 100+
Sorry Adizzii:

I thought I was done with this but it is now given me the 0 when less than 75 but not doing anthing when it is >=75.....

Any ideas?

Thanks Keith.
Apr 30 '08 #11
ADezii
8,834 Expert 8TB
Sorry Adizzii:

I thought I was done with this but it is now given me the 0 when less than 75 but not doing anthing when it is >=75.....

Any ideas?

Thanks Keith.
Try
Expand|Select|Wrap|Line Numbers
  1. =IIf(Val([Binding_Percentage]) < 75, 0, DSum("[GWP]", "ReQryForecast", "[Binding_Percentage] > = 75"))
Apr 30 '08 #12
kcdoell
230 100+
Try
Expand|Select|Wrap|Line Numbers
  1. =IIf(Val([Binding_Percentage]) < 75, 0, DSum("[GWP]", "ReQryForecast", "[Binding_Percentage] > = 75"))

ADezii:

Once I selected 75 or greater I received a #Error.....in the unbound text box. It did still place a "0" when I selected something less than 75.

I have read so much on Nz and Null values but still find it very confusing. Your thoughts?

Thanks,

Keith.
May 2 '08 #13
ADezii
8,834 Expert 8TB
ADezii:

Once I selected 75 or greater I received a #Error.....in the unbound text box. It did still place a "0" when I selected something less than 75.

I have read so much on Nz and Null values but still find it very confusing. Your thoughts?

Thanks,

Keith.
Does the [Binding_Percentage] Field contain strictly Numeric values, namely: 50, 60, 75, 80, etc...?
May 2 '08 #14
kcdoell
230 100+
Does the [Binding_Percentage] Field contain strictly Numeric values, namely: 50, 60, 75, 80, etc...?
ADezii:

[Binding_Percentage] is a combo box whose row source type is set to a value list. I have the row source set to:

"0%";"50%";"75%";"100%"

I used the "Val" because [Binding_Percentage] is a text box.

Thanks,

Keith.
May 5 '08 #15
kcdoell
230 100+
ADezii:

[Binding_Percentage] is a combo box whose row source type is set to a value list. I have the row source set to:

"0%";"50%";"75%";"100%"

I used the "Val" because [Binding_Percentage] is a text box.

Thanks,

Keith.

You have got me thinking. I changed [Binding_Percentage] to a number and set the row source set to:
0;50;75;100

Let me see if that changed anything,

Thanks,

Keith.
May 5 '08 #16
kcdoell
230 100+
That solved the problems and also eliminated other issues I was having except one.... I will open another thread to address that one.

Thanks!

Keith.
May 5 '08 #17
ADezii
8,834 Expert 8TB
That solved the problems and also eliminated other issues I was having except one.... I will open another thread to address that one.

Thanks!

Keith.
Anytime Keith, but you basically solved it yourself! (LOL).
May 5 '08 #18
kcdoell
230 100+
Yes, and that led me to solve another issue by myself:

Dividing by zero...

Wow, I am on a roll. Now it is back to my other problem that has been eating at me for over a week:

Creating a pivot table looking report……..


Any ideas would be helpfull.

Hope all is well,

Keith. :-)
May 5 '08 #19

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

Similar topics

9
by: Yaroslav Bulatov | last post by:
I made an array of 10 million floats timed how long it takes to sum the elements, here's what I got (millis): gcc -O2: 21 Python with numarray: 104 Python with Numeric: 302...
2
by: Targa | last post by:
<input NAME="TAXRATE" onBlur="this.form.TAX.value = (this.form.TAXRATE.value - 0) * (this.form.ITEM1TOTAL.value - 0) + (this.form.ITEM2TOTAL.value - 0) " Size="4"> In my TAX field I get...
7
by: Hank | last post by:
I have a report-summing problem using Access 2000. When a section runs over the end of the page, sometimes a detail gets picked up twice. Example: Customer Header XYZ Company Detail Section...
7
by: astro | last post by:
Anyone have suggestions on where to troubleshoot this error? Background: -Access 2k v. 9.0.6926 sp3 - front and backend on production server (wiindows 2k) -accessed via Citrix -front-end is...
4
by: King | last post by:
Hi I have two queries where in I calculated number of hours worked by an employee. Fields for the first query Meeting Id ( Auto Number ) Counselor ID ( text ) Date
4
by: dancole42 | last post by:
So I have an invoicing database based on two main forms: Orders and OrderLines. Orders has fields like: OrderID BillingMethod OrderDate CreditCard CCExp OrdSubTotal ShippingCharge
3
by: NewlytoSQL | last post by:
Hi all, im fairly new to SQL and im stuck half way through a query, im using DB2 here is what im tryng to do. i have a query that brings back an item number , shelf req, sum of all orders columns,...
3
by: kbeana | last post by:
I can't figure this out for the life of me. I have several fields that are set up as currency, and all have a decimal place of 2. I am summing some of them in the report footer, and it will be a...
3
by: OllyJ | last post by:
Hi guys hope you can help I have a text box for each day of the week in a form and numbers are entered into them (but sometimes they need to be left blank i.e. not 0). I am summing these values...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.