Results 1 to 5 of 5
  1. #1
    musicalogist is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    10

    Automatic Calculation in table

    Is there a way to make an automatic calculation in a table?

    This is why I need it:

    I have a table named "Invoices." The columns are Invoice number, Client, Concept, and SubTotal.

    BUT.... SOMETIMES there will be a sales tax included, SOMETIMES NOT. So I need two extra columns: One YES/NO labeled "Sales TAX" and another that will calculate a 16% sales tax IF the previous columned is marked "YES." If not, then the value will be 0.



    I need to store this value in the table, because it doesn't always apply.

    The Total (Subtotal+Sales TAX) will not be entered directly on the table, but displayed in a form/report

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Calculative Fields should be left to queries and are not necessary to include in the tables itself. Here I have just made one addition I have just included Yes/No Field to determine whether to apply Saletax.

    I have a Form and when you Check the SaleTax Check Box sale tax is calculated and show in the Form and so is the total

    Code used:

    Private Sub Form_Current()
    Select Case Me.SaleTax
    Case Is = True
    Me.Text10 = (16 / 100) * Me.Subtotal
    Case Is = False
    Me.Text10 = 0
    End Select

    End Sub

    Private Sub SaleTax_AfterUpdate()
    Select Case Me.SaleTax
    Case Is = True
    Me.Text10 = (16 / 100) * Me.Subtotal
    Case Is = False
    Me.Text10 = 0
    End Select
    End Sub

    I have applied the code to the afterUpdate Event of the SaleTax Check box and also the oncurrent event of the form. This is due to the fact that the SalexTax is populated according to the Sale Tax check box when you navigate and when the form opens.


    I have also prepared a query which has a SaleTaxAmt Calculative Field and total.


    refer to mdb attached:

    if this solves your problem mark the thread solved.

  3. #3
    musicalogist is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    10
    Wow, thanks! As a hard-core Access newb, it took me a while to get it to work, but it's perfect. thanks a lot!

    ummmm...how do I mark this as solved?

  4. #4
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Go to thread tools and select solved. If you have problems follow this link to learn how.
    https://www.accessforums.net/forum-s...lved-1828.html

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    mark the thread solved

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

Similar Threads

  1. Automatic backup
    By timpepu in forum Access
    Replies: 4
    Last Post: 08-14-2012, 01:38 PM
  2. automatic row insert
    By Jerry8989 in forum Forms
    Replies: 7
    Last Post: 09-29-2009, 06:50 AM
  3. Automatic Date insertion
    By wbeau in forum Access
    Replies: 0
    Last Post: 03-10-2009, 12:51 PM
  4. Automatic Syncronization
    By Katada in forum Programming
    Replies: 0
    Last Post: 04-25-2006, 03:36 AM

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