Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Percentages Query - Totalling Problem 1

Status
Not open for further replies.

DAmoss

Technical User
Jul 23, 2003
169
GB
Hi,

I have an Access 2003 query which generates a set of percentages, it's working nicely and correctly. As a quick check I thought I would total all the generated percentages together to see that they do indeed add up to 100%

This is the expression in my query:

TotalPcent: [DisabledPcent]+[NonDisabledPcent]+[NotKnownPcent]

But when the query is run I get the following on the screen instead:

5.62%48.86%45.52%

Is this a bug, why doesn't it total up my figues?

Here are the calculations for my individual percentages (without any zero error checking built in yet):

DisabledPcent: Format([TotDisabled]/[TotGME],"Percent")

NonDisabledPcent: Format([TotNonDisabled]/[TotGME],"Percent")

NotKnownPcent: Format([TotNotKnown]/[TotGME],"Percent")
 
the Format function produces strings, so you cannot add them

try this instead:

TotalPcent: Format((TotDisabled+TotNonDisabled+TotNotKnown)/TotGME,"Percent")


r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
r937

Cheers that works perfectly, I should have remembered 'format' returns a string value when used!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top