By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

IF statment problem

P: 16
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
Share this Question
Share on Google+
1 Reply


100+
P: 1,646
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.