473,414 Members | 1,964 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,414 software developers and data experts.

How to get a total of a particular product

29
I have a textbox called Engines Manufacturer. This texbox gives me the type of engine that is on the product. I also have a textbox called Annual Qty Est. This textbox give the number of engines that is on that particular product. I have 2 questions.

1. I want to know the code to put in my textbox control source to see only the Annual Qty Est for a particular Engines Manufacturer. Example: In the Engines Manufacturer column in the report I have an engine called "BS". I want to know only the Annual Qty Est for "BS" engines.

2. To further go on this, I also want to the the percentage for only "BS" engines. Example: Lets say that on the report the sum of all Annual Qty Est is 100,000. Out of that, "BS" engines is 10,000 out of that 100,000. I know this is 10%, but I don't know the code to put into my control source for that textbox.

Can I please get some help on this matter.
Feb 22 '07 #1
10 1733
Rabbit
12,516 Expert Mod 8TB
You're most likely looking for:
Expand|Select|Wrap|Line Numbers
  1. DSum("[Annual Qty Est]", "Table Name", "[Engines Manufacturer] = '" & Me.[Engines Manufacturer])
And:
Expand|Select|Wrap|Line Numbers
  1. 100*Me.[Name of Prior Control]/DSum("[Annual Qty Est]", "Table Name")
Feb 22 '07 #2
Scldb
29
You're most likely looking for:
Expand|Select|Wrap|Line Numbers
  1. DSum("[Annual Qty Est]", "Table Name", "[Engines Manufacturer] = '" & Me.[Engines Manufacturer])
And:
Expand|Select|Wrap|Line Numbers
  1. 100*Me.[Name of Prior Control]/DSum("[Annual Qty Est]", "Table Name")
I tried this code: DSum("[Annual Qty Est]", "Area_1_Products", "[Engine Manufacturer] = "Kohler" & Me.[Engine Manufacturer])

And all I get is a error stating: Syntax error (missing operator) in query expression "First ([DSum("[Annual Qty Est]", "Area_1_Products", "[Engine Manufacturer] = "Kohler" & Me].[[Engine Manufacturer])])'.

So what am I doing wrong? Can you please help?
The Area_1_Products is the query in which this report is trying to generate.
And Engine Manufacturer is correct instead of Engines Manufacturer.
Feb 22 '07 #3
Rabbit
12,516 Expert Mod 8TB
I tried this code: DSum("[Annual Qty Est]", "Area_1_Products", "[Engine Manufacturer] = "Kohler" & Me.[Engine Manufacturer])

And all I get is a error stating: Syntax error (missing operator) in query expression "First ([DSum("[Annual Qty Est]", "Area_1_Products", "[Engine Manufacturer] = "Kohler" & Me].[[Engine Manufacturer])])'.

So what am I doing wrong? Can you please help?
The Area_1_Products is the query in which this report is trying to generate.
And Engine Manufacturer is correct instead of Engines Manufacturer.
If you know Engine Manufacturer will always be Kohler, then it should be:
Expand|Select|Wrap|Line Numbers
  1. [Name of Textbox Control] = DSum("[Annual Qty Est]", "Area_1_Products", "[Engine Manufacturer] =  'Kohler'")
Otherwise, if you have a control on your form named Engine Manufacturer and that this can vary, it will be:
Expand|Select|Wrap|Line Numbers
  1. [Name of Textbox Control] = DSum("[Annual Qty Est]", "Area_1_Products", "[Engine Manufacturer] =  '" & Me.[Engine Manufacturer] & "'")
Also, this code needs to be in the after update event of the Engine Manufacturer textbox.
Feb 22 '07 #4
Scldb
29
If you know Engine Manufacturer will always be Kohler, then it should be:
Expand|Select|Wrap|Line Numbers
  1. [Name of Textbox Control] = DSum("[Annual Qty Est]", "Area_1_Products", "[Engine Manufacturer] =  'Kohler'")
Otherwise, if you have a control on your form named Engine Manufacturer and that this can vary, it will be:
Expand|Select|Wrap|Line Numbers
  1. [Name of Textbox Control] = DSum("[Annual Qty Est]", "Area_1_Products", "[Engine Manufacturer] =  '" & Me.[Engine Manufacturer] & "'")
Also, this code needs to be in the after update event of the Engine Manufacturer textbox.
What did/do you mean by your last statement "Also, this code needs to be in the after update event of the Engine Manufacturer textbox". I don't quite understand what you mean by this? Can you please elaborate?
Feb 22 '07 #5
Scldb
29
What did/do you mean by your last statement "Also, this code needs to be in the after update event of the Engine Manufacturer textbox". I don't quite understand what you mean by this? Can you please elaborate?
Now can you get me the code for the % of Kohler engines. I got the number 5,561 just for Kohler engines(which is correct). But the total (sum of all Annual Qty Est is 29,543. I want to know the code to put in a textbox that will give the the % of Kohler engines.
Feb 22 '07 #6
Rabbit
12,516 Expert Mod 8TB
In the properties of the control, in the Events tab, there are certain events that can trigger code or a macro. You click the triple dotted button next to the event that you want to enter code and you select Code Builder from the pop up box. This will bring you to the Visual Basic Editor. From here you enter in the code you want to run whenever the event triggers.
Feb 22 '07 #7
Scldb
29
In the properties of the control, in the Events tab, there are certain events that can trigger code or a macro. You click the triple dotted button next to the event that you want to enter code and you select Code Builder from the pop up box. This will bring you to the Visual Basic Editor. From here you enter in the code you want to run whenever the event triggers.
I'll give that a try. How about the % code that I want to put in the control source of another texbox. I know that there is 29543 (sum of all Annual Qty Est) and 5,561 of that is Kohler. Which is about 18.82%, but I don't know the code to put in my control source.
Feb 22 '07 #8
Rabbit
12,516 Expert Mod 8TB
If you look at post #2, the first code box is for the number the second code box is for the percentage.
Feb 22 '07 #9
Scldb
29
If you look at post #2, the first code box is for the number the second code box is for the percentage.
Thank you for helping me out. Hope to get more help from you in the future.
Feb 22 '07 #10
Rabbit
12,516 Expert Mod 8TB
Not a problem, glad to help.
Feb 22 '07 #11

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

Similar topics

1
by: webguy262 | last post by:
I'm trying to modify this script... <script language="JavaScript" type="text/javascript"> <!-- /* This script is Copyright (c) Paul McFedries and Logophilia Limited...
14
by: Kevin G. Anderson | last post by:
What: CAUG Meeting - QuickBooks IIF Files; Total Access Analyzer; CAUG Social When: Thursday, May 25, 2006, 6PM Who: Chris Monaghan and Kevin Anderson Where: The Information Management Group...
4
by: PercyPercy | last post by:
For some reason I can't write the proper query to get a simple total from a single table. Here is the basic table design: Transaction ID___Product ID___ Transaction Date____Transaction Quantity...
1
by: nhl66pens | last post by:
I have this statement: SELECT product, decode(region, '501', 'Northeast', '502', 'Midwest', '503', 'West', '504', 'South', '505', 'Southeast', '506', 'MidAtlantic', '520', 'Molecular', '901', 'Ind...
3
by: lionelm2007 | last post by:
Hi there, I have a form called Production Run and has a field to select a product. I would like to grab the recipe for a particular product from product recipe table, do some calculations on the...
0
by: nityaprashant | last post by:
Hello.. could u plz help me? i have template column inside grid view.. in that one link button called Remove this? when i click on that link button confirmation box like "Are u sure u want...
3
by: MyWaterloo | last post by:
I need some help with an inventory type question. To lay the foundation... I have an inventory database that keeps track of parts for rebuilds. The tables are: CATEGORIES which is linked to table...
2
by: alwaali | last post by:
Hi I need help please This is my project and i need a help to solve it with you A page of text is to be read and analyzed to determine number of occurrences and locations of different words. The...
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
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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.