Results 1 to 8 of 8
  1. #1
    bar891 is offline Novice
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    20

    How to save calculations

    I'm a Newbie to access, I have a form that has mulitple text boxes with formula in them calculating from an input total. What i need to do is store the formula calculations so i can then calculate those answers to get to my totals. I read somewhere that you shouldn't store calculations, so i am confused. If someone has a better way of doing this or point me in the right direction.


    Many Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The conventional wisdom is store raw data and do calculations in queries and reports. Result of a simple calc such as Quantity * Price doesn't need to be saved. There are situations when saving calculated results can be justified.

    Total can be generated on calculated fields. Do an aggregate query using GROUP BY (Totals). Or do summary calcs in report header/footer sections. These are both basic Access functionality and Access Help has guidelines.
    Last edited by June7; 05-07-2013 at 11:12 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    bar891 is offline Novice
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    20
    So i have some text boxes with formula in them that work correctly. How do i do a query on that text box?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You don't. If the calculation is in textbox then it has a life only in the textbox. Alternative is to do calculation in query and bind textbox to the constructed field. Access Help has guidelines on how to do calculations in queries.

    Also review http://allenbrowne.com/casu-14.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    It depends on what kind of calculations you're doing. If all you're doing is very simple (grade-school) math, then check out my code here for a way to save calculations in a database.

    This is very early code for me though, so it doesn't follow any order of precedence, it's strictly first-come first-served!

    Example: 3 + 2 * 5 should equal 13. With the code I linked, it would come out to 25

  6. #6
    DepricatedZero's Avatar
    DepricatedZero is offline Cthulhu Fhtagn!
    Windows 8 Access 2007
    Join Date
    Apr 2013
    Location
    Cincinnati
    Posts
    65
    You make PEMDAS sad Rawb :P

  7. #7
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Yeah, well he deserves to be sad after what he did to me in school!

    On a side note, this post got me interested in saved equations again. After a little looking around, I think I've found some code that allows for advanced math to be processed from a string variable with proper precedence! I'll post here in a few with the code if I can get it to work!

  8. #8
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    It works! Hooray!!!

    Attached is a copy of the original source code along with a (slightly engrish) manual on the whole thing. Note that you need to import BOTH the .cls file and the .bas file into your database for it to work.
    Attached Files Attached Files

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 10-08-2012, 08:40 AM
  2. Replies: 8
    Last Post: 09-27-2012, 11:12 AM
  3. Replies: 10
    Last Post: 06-20-2012, 09:50 AM
  4. calculations??
    By richrit in forum Access
    Replies: 1
    Last Post: 04-11-2012, 05:06 PM
  5. Replies: 9
    Last Post: 01-20-2011, 02:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums