making a feild conditional upon another

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

    #1

    making a feild conditional upon another

    I want the feild total to display the total cost of an item, If the item has vat a yes no box is ticked in the field vat and I have the price of the item without vat. I want the feild total to display [price]*vat rate if the vat box is ticked and I want it to display the [price] if the vat box is not ticked but i'm at a loss as to what to do any help?
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Originally posted by Richard Gilmore
    I want the feild total to display the total cost of an item, If the item has vat a yes no box is ticked in the field vat and I have the price of the item without vat. I want the feild total to display [price]*vat rate if the vat box is ticked and I want it to display the [price] if the vat box is not ticked but i'm at a loss as to what to do any help?
    Do you want to do this using a form or to default the value for new records in a table. For existing records you will have to run an update query.

    Let me know and I'll provide instructions.

    Comment

    • MMcCarthy
      Recognized Expert MVP
      • Aug 2006
      • 14387

      #3
      Originally posted by mmccarthy
      Do you want to do this using a form or to default the value for new records in a table. For existing records you will have to run an update query.

      Let me know and I'll provide instructions.
      Richard don't send me PM's reply to the post

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Originally posted by mmccarthy
        Do you want to do this using a form or to default the value for new records in a table. For existing records you will have to run an update query.

        Let me know and I'll provide instructions.
        OK

        Make the default value of the field as follows:

        =IIf(vat="Yes",[price]+(([price]*17)/100), [price])

        I used 17% as I don't know what your vat rate is.

        Comment

        • Richard Gilmore
          New Member
          • Nov 2006
          • 16

          #5
          Hm i get a error saying database does not recognise the field vat in the default value

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Originally posted by Richard Gilmore
            Hm i get a error saying database does not recognise the field vat in the default value
            do you have a field in your table called vat?

            Comment

            • Richard Gilmore
              New Member
              • Nov 2006
              • 16

              #7
              Originally posted by mmccarthy
              do you have a field in your table called vat?
              yeah I have a feild called vat and price

              Comment

              • MMcCarthy
                Recognized Expert MVP
                • Aug 2006
                • 14387

                #8
                Originally posted by Richard Gilmore
                yeah I have a feild called vat and price
                Its probably not going to allow you to set a conditional default value in the table. You will have to look at doing it in a form.

                Comment

                • Richard Gilmore
                  New Member
                  • Nov 2006
                  • 16

                  #9
                  Originally posted by mmccarthy
                  Its probably not going to allow you to set a conditional default value in the table. You will have to look at doing it in a form.
                  ok that will do if thats the case what is the method behind that

                  Comment

                  • MMcCarthy
                    Recognized Expert MVP
                    • Aug 2006
                    • 14387

                    #10
                    In a data entry form based on the table. Put an AfterUpdate event on the vat textbox as follows. You will need to put the same code in the AfterUpdate event of the price field.

                    Code:
                     
                    Private Sub vat_AfterUpdate()
                     
                    Me.TotalPrice 
                    =IIf(Me.vat="Yes",Me.price+((Me.price*17)/100),Me.price)
                     
                    End Sub

                    Comment

                    • Richard Gilmore
                      New Member
                      • Nov 2006
                      • 16

                      #11
                      Originally posted by mmccarthy
                      In a data entry form based on the table. Put an AfterUpdate event on the vat textbox as follows. You will need to put the same code in the AfterUpdate event of the price field.

                      Code:
                       
                      Private Sub vat_AfterUpdate()
                       
                      Me.TotalPrice 
                      =IIf(Me.vat="Yes",Me.price+((Me.price*17)/100),Me.price)
                       
                      End Sub

                      Thanks managed to get it sorted

                      Comment

                      Working...