Results 1 to 5 of 5
  1. #1
    visidro is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    23

    Calculation of amount boxes

    I am farily new to access need help with a calculation please



    We have a form where we enter various amounts and a box where these are added together to calculate taxes.
    This amount is shown on the screen but we need to save this total amount in the table where it can be used in other calculations in other forms

    the control in the box looks like this: =[registration fee]+[membership fee]+[fee per term]+[additional classes fee]+[costume]+[books]-[discount]+[applicable gst]+[uniform fee]

    How can I get the result of this formula saved in another table field?

    thank you
    victor

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Usually a bad idea to save calculated result. The calculation can be done whenever needed.

    However, to do so will required VBA code. The real trick is figuring out what event. Perhaps in the form BeforeUpdate simply:

    Me!fieldname = Me.textboxname

    Could any of those fields be Null? If so, need to handle Null because calculation with Null will result in Null. Try:

    Nz([additional classes fee],0)
    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
    visidro is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    23
    all the fields have a $0 as their default value.

    I have added an Event Procedure for the "Before Update" on the form with this:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me!totalamount = Me.amount
    End Sub


    Nothing is hapening ... not sure I understand the "Me"

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Me is alias for the object (form or report) that the code is behind. It is shorthand for Forms!formname.

    The BeforeUpdate event won't trigger unless something in the record is entered/edited.
    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
    visidro is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    23
    Excellent!!

    Thank you; again!
    victor

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

Similar Threads

  1. Calculation Field in table vs Query calculation
    By Leonidsg in forum Database Design
    Replies: 18
    Last Post: 02-28-2013, 09:38 PM
  2. Replies: 4
    Last Post: 11-30-2011, 07:51 AM
  3. limiting amount of records
    By yaro.kobzar in forum Programming
    Replies: 1
    Last Post: 05-17-2011, 07:01 PM
  4. Replies: 9
    Last Post: 07-16-2010, 09:25 AM
  5. Replies: 2
    Last Post: 06-18-2006, 10:50 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