Calculating VAT

SteveF

Registered User.
Local time
Today, 21:00
Joined
Jul 13, 2008
Messages
191
I'm sure this has been asked before, but I have searched and can't find the answer.

I'm writing a simple invoicing utility but want the VAT rate to be variable. I have:
tbl_invoice and tbl_vatrate. The VAT rate in the invoice table looks the rate of from the VAT table.

The problem is that trying to run a query to calculate VAT returns a rounded number and I can't stop it happening.

All the numbers in the query are set to currency, with the exception of VAT rate which is set to general. The numbers in the invoice table are set to currency, with the exception of VAT rate which is set to Double, General Number and 1 decimal place.

It's driving me cuckoo, any ideas?
 
Is your problem just the rounding - ie, nothing to with VAT as such and or the calculation of the variable VAT rate??

If just rounding, how is VAT calculated, by line item or Invoice Total?
 
It's calculated by the total. So I have an amount, less discount = subtotal, subtotal x vat rate theoretically equals vat amount
 
I should say that I've had no problems with this before but have hard coded the vat rate in the past. That proved to be a mistake, and a royal pain in the butt to get over, so this time I'm trying to do the thing properly.

I'm suspicious of the 'vat rate' number.
 

That doesn't help, though thanks for looking. I can do the maths regarding vat, this is a different issue I think.

Access is rounding the number calculated up and I can't see why.

If I calculate vat off the subtotal directly rather than the vat rate number pulled from another table it works fine. This has to be something to do with the vat rate coming from a vat rate table rather than being hard coded.
 
Can we see what the output looks like?

Use: CCur(Round(calculation here, 2))
 
Here goes, see if this uploads ok.

I have the calculation: VAT Amount: [Subtot]*[VAT_Rate]/100
 

Attachments

  • Database.jpg
    Database.jpg
    23.6 KB · Views: 290
So the VAT_Amount should be the same as Expr1 right? You're VAT_Rate is returning 2 from my calculations. Are you using a subquery?

Are you able to post the problem part of your db?
 
That's right, it should be the same.

There is no sub-query, the VAT rates are input straight into the table by a vat rate form. From there, there is a lookup field in the invoice table to pull in the appropriate vat rate.

I think I'm doing something dumb with the vat rate number, but I can't see what.

How would I post part of the database?
 
You mentioned using a lookup field. Have a look at this link re lookup fields:

http://www.mvps.org/access/lookupfields.htm

Looks like something wrong with the value that VAT_Rate is returning.

To upload:

1. Remove sensitive and keep some erroneous data for testing
2. Perform a Compact & Repair
3. Click the GO ADVANCED button and you will find a button call MANAGE ATTACHMENTS
4. Browse for you db, Upload, wait for it to appear on the small window
5. Close the window and REPLY
 
I've exported the tables and query to a new DB. The problem is still there and more convinced now that it is the vat rate that is the problem.
 

Attachments

You mentioned using a lookup field. Have a look at this link re lookup fields:

http://www.mvps.org/access/lookupfields.htm

Looks like something wrong with the value that VAT_Rate is returning.

To upload:

1. Remove sensitive and keep some erroneous data for testing
2. Perform a Compact & Repair
3. Click the GO ADVANCED button and you will find a button call MANAGE ATTACHMENTS
4. Browse for you db, Upload, wait for it to appear on the small window
5. Close the window and REPLY

Thanks for your time on this by the way; it's appreciated.
 
So reading that link lookup fields = bad. What is the alternative?
 
So reading that link lookup fields = bad. What is the alternative?
Good point Steve. Just reminded me to look in the lookup field. Remember I mentioned I calculated it was returning 2? That 2 is the Vat Rate ID associated with the Vat Rate 17.5. See why lookup fields aren't good?

Perform the link directly using the Relationships window.
 
Ha! I knew it was that vat rate! So it's the vat rate rounding first and then the query calculating the rounded figure? I will try and fix it.
 
It's not rounding. This is the thing about lookup fields, the VAT_Rate that is being returned for calculation is the Vat Rate ID, not the Vat Rate itself. So instead of it picking the second column of that field, which is your VAt rate, it's picking the bound column which is Rate ID. Do you get it now?
 
I think the penny is dropping. I am now trying to create the correct relationship between the two tables...
 
Great. So in that query you will now need to join the vatrates table with your invoices table and include the VAT Rate field from the vatrates table.
 

Users who are viewing this thread

Back
Top Bottom