Solved

Use query data to do a total  calculations in a text box  on a form.

Posted on 2013-01-06
10
378 Views
Last Modified: 2013-01-14
I have a field in a query that is called Percentages.


i Have a text box that needs to take the information from precentages and total the precentages. I can total a table information is it possible to total a query caluculation in a text box?


=DSum("[Scope]","tblScopeUnit")


Like this some how?

=DSum("[Percentages]","Queryname")

Here is my database



for example
 A door installed  a=10% b=20% c=30%    percentages = 60%
 B door installed  a=15% b=30% c=20%    Percentages =  65%

Total= 125%
MODKitProduction.zip
0
Comment
Question by:gigifarrow
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 10

Expert Comment

by:etech0
ID: 38749670
Yes. Set the datasource for that textbox to be =DSum("[Percentages]","Queryname").
0
 

Author Comment

by:gigifarrow
ID: 38749759
thank you for your time and help! But the query

is embedded in the form in the record source . so I dont know what the name would be
I used

=DSum("[Percentages]","frmTempleFullUp:Query Builder")

i get  this   error? as an error.



if you have the time could you please look at my database and tell me what the name would  be,

in the record source of the form it has this

SELECT tblTempleFacilityFullup.Production, tblTempleFacilityFullup.InShopDate, tblTempleFacilityFullup.SerialNumber, tblTempleFacilityFullup.Unit, tblTempleFacilityFullup.Induction, tblTempleFacilityFullup.TearDown, tblTempleFacilityFullup.Provision, tblTempleFacilityFullup.E1GroundInsert, tblTempleFacilityFullup.ReliefHoleExtinguisher, tblTempleFacilityFullup.AssemblyA, tblTempleFacilityFullup.FuelShotOffSleeve, tblTempleFacilityFullup.AsemblyB, tblTempleFacilityFullup.CEPUpgrade, tblTempleFacilityFullup.AFESCEPSwitch, tblTempleFacilityFullup.AssemblyC, tblTempleFacilityFullup.ERRHandle, tblTempleFacilityFullup.DriverSeat, tblTempleFacilityFullup.AssemblyD, tblTempleFacilityFullup.HotBoxEnhanceMent, tblTempleFacilityFullup.AssemblyE, tblTempleFacilityFullup.LegacyBattery, tblTempleFacilityFullup.[LED/ERR], tblTempleFacilityFullup.T161Track, tblTempleFacilityFullup.AFES, tblTempleFacilityFullup.HotBox, tblTempleFacilityFullup.BASSM2, tblTempleFacilityFullup.GunnersSeatStopRework, tblTempleFacilityFullup.RoadTest, tblTempleFacilityFullup.QC, tblTempleFacilityFullup.OutDuction, tblTempleFacilityFullup.PercentageComplete, tblTempleFacilityFullup.DateCompleted, tblTempleFacilityFullup.DateReturned, tblTempleFacilityFullup.Remarks, Format(Abs(([tblTempleFacilityFullup]![Induction]*6+[tblTempleFacilityFullup]![TearDown]*10+[tblTempleFacilityFullup]![Provision]*10+[tblTempleFacilityFullup]![AssemblyA]*10+[tblTempleFacilityFullup]![AsemblyB]*10+[tblTempleFacilityFullup]![AssemblyC]*10+[tblTempleFacilityFullup]![AssemblyD]*10+[tblTempleFacilityFullup]![AssemblyE]*10+[tblTempleFacilityFullup]![RoadTest]*4+[tblTempleFacilityFullup]![QC]*10+[tblTempleFacilityFullup]![OutDuction]*10)/100),"00.0%") AS Percentages FROM tblTempleFacilityFullup;
0
 
LVL 10

Expert Comment

by:etech0
ID: 38749771
This way might be easier:

In the properties box for the form, click the button with three dots next to recordsource.

Then, add a field to the query, and you can have it do the calculations. Once youpen the querybuilder to do that, you should be able to see the names of your fields.
0
 
LVL 39

Expert Comment

by:als315
ID: 38749994
You can sum field directly (Procent fields were changed from text to numeric). Look at sample.
But may be better to use subform with results from query. Dlookups took too many time.
MODKitProduction.zip
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38751305
"frmTempleFullUp:Query Builder"
..is that the actual name of the table/query?

Try changing it to something without the special characters...
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:gigifarrow
ID: 38756297
When I click on the record source to see the the query on the tab it has the name "frmTempleFullUp:Query Builder" .

I dont know how to change it because it doesnt show up as a query,on the Navigation under queries.

 I need the total of precentages from a field that is not in the table but was addd to  the query.
So when I put,
TotalPrentages:=DSum("[Percentages]","frmTempleFullUp:Query Builder")  
 error says cant find table or query.


When I go to save it to see what the name of the query is. It ask me if I want to save the record of the SQL statement? it doesnt tell me the name of the query.
0
 
LVL 10

Expert Comment

by:etech0
ID: 38757170
Go to the record source box, and click the little button with three dots that you'll see at the right side.
0
 

Author Comment

by:gigifarrow
ID: 38762905
When I click on the record source where the dots are on the right side the query opens up. on the tab it has the name "frmTempleFullUp:Query Builder" .

When I go to save it to see what the name of the query is. It ask me if I want to save the record of the SQL statement? it doesnt tell me the name of the query.

When I put it in a text box I get a error. It seems to me that you cant use DSum with a query but you can use a Dlookup but it doesnt total with a Dlookup. made a new query called qryTemple and tried this.

=DLookUp("[Percentage]","qrytemple"," [Unit ]= ('278th ABCT')") works but doesnt total
=DSum("[Percentage]","qrytemple"," [Unit ]= ('DRS TEST')") gives me a error everytime?
0
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 38764047
If you remove Format from your query:
Format(Abs(([tblTempleFacilityFullup]![Induction]*6+[tblTempleFacilityFullup]![TearDown]*10+[tblTempleFacilityFullup]![Provision]*10+[tblTempleFacilityFullup]![AssemblyA]*10+[tblTempleFacilityFullup]![AsemblyB]*10+[tblTempleFacilityFullup]![AssemblyC]*10+[tblTempleFacilityFullup]![AssemblyD]*10+[tblTempleFacilityFullup]![AssemblyE]*10+[tblTempleFacilityFullup]![RoadTest]*4+[tblTempleFacilityFullup]![QC]*10+[tblTempleFacilityFullup]![OutDuction]*10)/100),"00.0%") AS Percentages
replace with:
Abs(([tblTempleFacilityFullup]![Induction]*6+[tblTempleFacilityFullup]![TearDown]*10+[tblTempleFacilityFullup]![Provision]*10+[tblTempleFacilityFullup]![AssemblyA]*10+[tblTempleFacilityFullup]![AsemblyB]*10+[tblTempleFacilityFullup]![AssemblyC]*10+[tblTempleFacilityFullup]![AssemblyD]*10+[tblTempleFacilityFullup]![AssemblyE]*10+[tblTempleFacilityFullup]![RoadTest]*4+[tblTempleFacilityFullup]![QC]*10+[tblTempleFacilityFullup]![OutDuction]*10)/100) AS Percentages
and dsum should work.
0
 
LVL 10

Expert Comment

by:etech0
ID: 38765907
Try taking out the parentheses and brackets from this:
=DSum("[Percentage]","qrytemple"," [Unit ]= ('DRS TEST')")

Like this:
=DSum("[Percentage]","qrytemple"," Unit = 'DRS TEST'")

If that  doesn't work, also try taking out the single quotes from around DRS TEST.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now