IF statment problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Gilmore
    New Member
    • Nov 2006
    • 16

    #1

    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
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by Richard Gilmore
    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
    Code:
    If Stocktbl.[Vat] Then
       Stocktbl.[Total] = Stocktb.[Price] * 1.175
    Else
       Stocktbl.[Total] = Stocktbl.[Price]
    End If
    And if you add a Tax table:
    Code:
    If Stocktbl.[Vat] Then
       Stocktbl.[Total] = Stocktbl.[Price] _
               + (Stocktbl.[Price] * Taxtbl.[VAT])
    Else
       Stocktbl.[Total] = Stocktbl.[Price]
    End If
    Good luck

    Comment

    Working...