Results 1 to 7 of 7
  1. #1
    simpleman is offline Novice
    Windows Vista Access 2003
    Join Date
    Nov 2009
    Posts
    3

    Angry access query formula

    Hi I am a self employed man with a limited knowledge of access but I like using it and enjoy what is to me a challenge.

    When our wonderfull leader changed the VAT rate to 15% I altered my VAT formula to IIf([SALES ID]<16988,[SUB TOTAL]*[VAT RATE]) & IIf([SALES ID]>16987,[SUB TOTAL]*[NEW RATE]) worked brilliantly!!

    Now soon comes Jan and we are returning to 17.5%, in my infinate wisdom I thought adding & IIf([SALES ID]>19450,[SUB TOTAL]*[VAT RATE]) would do the trick and take me back to the old rate but it does not work, been tearing my hair out since but cannot make anything do the trick.



    Any help would be much appreciated

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    That is not a valid IIF statement. Care to post it again?

  3. #3
    simpleman is offline Novice
    Windows Vista Access 2003
    Join Date
    Nov 2009
    Posts
    3

    Smile

    Hi and many thanks for taking the trouble to reply, IIf([SALES ID]<16988,[SUB TOTAL]*[VAT RATE]) & IIf([SALES ID]>16987,[SUB TOTAL]*[NEW RATE]) did work, been using it for over a year, on receiving your reply I had a fiddle and realised that>

    IIf([SALES ID]<16988,[SUB TOTAL]*0.175) & IIf([SALES ID]>16987,[SUB TOTAL]*0.15) worked just as well and meant I could delete two fields from my database [vat Rate] and [new rate]

    I figured out in the end that I was asking it to perfom the same sum, on top by adding & IIf([SALES ID]>18450,[SUB TOTAL]*0.175)

    I have ended up after not sleeping all night (why is this stuff so addictive)
    with VAT: IIf([SALES ID] Between 0 And 16987,[SUB TOTAL]*0.175) & IIf([SALES ID] Between 16988 And 18450,[SUB TOTAL]*0.15) & IIf([SALES ID]>18450,[SUB TOTAL]*0.175) this seems to works fine.

    Anyway thanks again for taking the trouble to reply it is appreciated and you made me go back and look harder

  4. #4
    genesis is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    39
    can you state what is that sales id there?

    also your IIF statement is erroneous!

    syntax is iif(criteria,valueiftrue,iif(criteria,valueiftrue, if(criteria,valueiftrue,valueiffalse)))

    there is no use of "&" there.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I also have a problem with your use of the ampersand "&".

  6. #6
    simpleman is offline Novice
    Windows Vista Access 2003
    Join Date
    Nov 2009
    Posts
    3

    Smile

    Guys got to tell that it works,
    VAT: IIf([SALES ID] Between 0 And 16987,[SUB TOTAL]*0.175) & IIf([SALES ID] Between 16988 And 18450,[SUB TOTAL]*0.15) & IIf([SALES ID]>18450,[SUB TOTAL]*0.175)
    may not be right but it honestly does work
    I did state that I am a self taught amateur .

    Sales ID is actually the invoice no and the idea is that up to invoice 16987
    the tax is calculated 17.5% from 16988 to and including 18450 tax is calculated at 15% and from January next year used 18450 just as a figure for the test, it goes back to 17.5%

    Having said all that the formula below based on what genesis suggested also works and is no doubt the correct way to do it, I have now changed it in my database and many thanks for the lesson.

    VAT: IIf([SALES ID] Between 0 And 16987,[SUB TOTAL]*0.175,IIf([SALES ID] Between 16988 And 18450,[SUB TOTAL]*0.15,IIf([SALES ID]>18450,[SUB TOTAL]*0.175)))

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    We believed you, it was just that the syntax was strange. Evently the Access parser will accept either a comma "," or the ampersand "&" there. I probably would have created a public function in a standard module for your function and used a Case structure. Easier to understand and maintain in my opinion.

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

Similar Threads

  1. Replies: 0
    Last Post: 09-03-2009, 01:58 PM
  2. Concatenate Formula
    By Shingo in forum Programming
    Replies: 1
    Last Post: 07-25-2009, 09:14 AM
  3. Formula question on Report
    By FestoAccessBuilder in forum Reports
    Replies: 0
    Last Post: 03-10-2009, 10:21 AM
  4. formula on report??
    By dike969 in forum Access
    Replies: 0
    Last Post: 03-05-2007, 01:58 AM
  5. Max formula in Access
    By mohsin74 in forum Programming
    Replies: 2
    Last Post: 12-26-2006, 07:21 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