467,881 Members | 1,178 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,881 developers. It's quick & easy.

IF statment problem

New to coding and I don't know why this doesn't work get an error 424 it is for my access database

Public Function vatty()

If Stocktbl.[Vat] = True Then
Stocktbl.[Total] = "Stocktb.[Price]*1.175"
Else
Stocktbl.[Total] = "Stocktbl.[Price]"
End If


End Function
Nov 7 '06 #1
  • viewed: 810
Share:
1 Reply
1GB
New to coding and I don't know why this doesn't work get an error 424 it is for my access database

Public Function vatty()

If Stocktbl.[Vat] = True Then
Stocktbl.[Total] = "Stocktb.[Price]*1.175"
Else
Stocktbl.[Total] = "Stocktbl.[Price]"
End If


End Function
Hi. I imagine Vat is boolean and Total and Price are both currency types.
I suggest you add a VAT table so that your code will endure any changes in VAT.

You will not be successful in assigning a string value to a currency data type
Try this
Expand|Select|Wrap|Line Numbers
  1. If Stocktbl.[Vat] Then
  2.    Stocktbl.[Total] = Stocktb.[Price] * 1.175
  3. Else
  4.    Stocktbl.[Total] = Stocktbl.[Price]
  5. End If
  6.  
And if you add a Tax table:
Expand|Select|Wrap|Line Numbers
  1. If Stocktbl.[Vat] Then
  2.    Stocktbl.[Total] = Stocktbl.[Price] _
  3.            + (Stocktbl.[Price] * Taxtbl.[VAT])
  4. Else
  5.    Stocktbl.[Total] = Stocktbl.[Price]
  6. End If
  7.  
  8.  
Good luck
Nov 7 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by e_AK_05 | last post: by
9 posts views Thread by Appel | last post: by
1 post views Thread by Maria | last post: by
1 post views Thread by Me, Myself, and I | last post: by
4 posts views Thread by huzzaa | last post: by
1 post views Thread by zeebiggie | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.