Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 17th, 2005, 07:19 AM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query Calculations

Hi all, I am new to this forum and have not really designed any advanced databases. I am trying to designa database for our local minor softball league and am having troubles getting a calculation in a query to work right. I have a number of field such as;

H (hits) BB (balls on base) AB (at bats) HBP (hit by pitch)
33 12 62 0

First I am trying to add H + BB + HBP together then devide by AB + BB + HBP

Here is what I came up with;
OBP: Sum(([Batting]![H])+([Batting]![BB])+([Batting]![HBP]))/(([AB])+([Batting]![BB])+([Batting]![HBP]))

I am guessing the problem is with the "[" or "("

Sure would appreciate it if you could help...thanks.

  #2 (permalink)  
Old August 17th, 2005, 09:39 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

If you are only taking this data from one table (Batting) then you don't need to state that in your report. I am assuiming it is a control in a report. Perhaps a query. I would use a query and pass that to the report.

OBP:(([H]+[BB]+[HBP])/([AB]+[BB]+[HPB]))

This should work. This also assumes that your table fields are all number fields (integer, long, etc.)

HTH

mmcdonal
  #3 (permalink)  
Old August 17th, 2005, 09:56 AM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, my mistake was even though I just had numbers in all the fields, I had them as text fields, when i switched to number fields it worked fine. Cheers.

  #4 (permalink)  
Old August 17th, 2005, 11:59 AM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Another question if I may, could you please tell me the imput mask to use in order not to show a zero in from of a decimal Ex. I want 0.654 to show as .654
Thanks again



Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Calculations edove ASP.NET 2.0 Basics 0 March 30th, 2007 07:05 AM
simply query calculations!!!!!! thedom Access 0 March 13th, 2007 06:37 PM
DateTime Calculations mrookey C# 4 June 2nd, 2006 06:18 AM
Positioning Calculations rit01 ASP.NET 1.x and 2.0 Application Design 3 February 22nd, 2006 03:10 PM
DateTime calculations sudarshan73 SQL Server 2000 1 March 15th, 2005 03:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.