Help with code??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dayav07
    New Member
    • Jan 2010
    • 8

    #1

    Help with code??

    Hi. I am trying to make a cashbook in Access for my fathers business.. I am new to Access and Bytes. I made a table with the following fields: ID (primary key), Supplier, Date, Invoice Number, Details, Zero Rated (this is a check box with a yes/no data type), Amount, VAT. I highlighted the VAT column in design view and went to default value and put this in

    Code:
    IF([Zero Rated]=0,[Amount]*0.14,0)
    BTW the name of the table is Purchases. I am getting errors with this formula though. Please help me where I am going wrong and also tell me what I am doing wrong.. I am keen to learn Access. :)

    dayav07
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    If it's in the form field try:
    Code:
    =IIF([Zero Rated]=0,[Amount]*0.14,0)
    Personally I would use a separate TaxRate table and get the % from there for the calculation.

    Nic;o)

    Comment

    • dayav07
      New Member
      • Jan 2010
      • 8

      #3
      Hey man.. I tried that and it works but then in the form if i put in 10 in the amount the vat will show 1.4 but then when i press enter to record it it doesnt appear in the VAT column in the table..

      any ideas?

      Comment

      • nico5038
        Recognized Expert Specialist
        • Nov 2006
        • 3080

        #4
        A field holding an "=" is by definition "Unbound", and thus not stored.
        Due to the normalization rules we normally don't store results of an algoritm, but apply it when needed on the "basic" data. Thus when the basics change the result will still be "in line".
        The same IIF() can be used in a query, thus actively creating the column when needed.

        Getting the idea ?

        Nic;o)

        Comment

        Working...