Solved

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

Posted on 2013-01-06
10
392 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

867 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

22 Experts available now in Live!

Get 1:1 Help Now