VB Calculate and update fields in Forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sven Seljom

    VB Calculate and update fields in Forms

    I want to take the value from one form-field, deduct the VAT and return the
    value in another form-field. I have made a Public Function for this and
    attached it to the text-box. Can anybody help me with the correct syntax?

    Here's what I got so far:

    Public Function specify_VAT()
    Dim vat
    vat = "[price]/1.24"
    End Function

    I suppose what I want to know is how to put the result of this into the
    form-field in question. Any thoughts appreciated.

    Sven



  • PC Datasheet

    #2
    Re: VB Calculate and update fields in Forms

    Sven,

    You don't need to store the VAT since it is a calculated piece of data. So in
    the textbox where you want to display the VAT, put this expression in the
    control source property:

    = [price]/1.24

    You store only Price in your table and when you want to display VAT in a form or
    report, you calculate it.


    --
    PC Datasheet
    Your Resource For Help With Access, Excel And Word Applications



    "Sven Seljom" <sven@seljom.no > wrote in message
    news:fubpb.3671 $mf2.47488@news 4.e.nsc.no...[color=blue]
    > I want to take the value from one form-field, deduct the VAT and return the
    > value in another form-field. I have made a Public Function for this and
    > attached it to the text-box. Can anybody help me with the correct syntax?
    >
    > Here's what I got so far:
    >
    > Public Function specify_VAT()
    > Dim vat
    > vat = "[price]/1.24"
    > End Function
    >
    > I suppose what I want to know is how to put the result of this into the
    > form-field in question. Any thoughts appreciated.
    >
    > Sven
    >
    >
    >[/color]


    Comment

    • Sven Seljom

      #3
      Re: VB Calculate and update fields in Forms

      Yes, that works, but I do need to use a Public Function to perform the
      operation.


      Comment

      • Fletcher Arnold

        #4
        Re: VB Calculate and update fields in Forms


        "PC Datasheet" <spam@nospam.co m> wrote in message
        news:dHbpb.2374 $9M3.737@newsre ad2.news.atl.ea rthlink.net...[color=blue]
        > Sven,
        >
        > You don't need to store the VAT since it is a calculated piece of data. So[/color]
        in[color=blue]
        > the textbox where you want to display the VAT, put this expression in the
        > control source property:
        >
        > = [price]/1.24
        >
        > You store only Price in your table and when you want to display VAT in a[/color]
        form or[color=blue]
        > report, you calculate it.[/color]


        PC Datasheet - (Steve?)
        While I'm sure this is not news to you, it might be worth clarifying
        something for the benefit of the OP. Although in general you should not
        store calculated values, something like VAT is a bit special and might need
        to be stored for 2 reasons:

        1. Rounding - I have seen different companies round in different ways.
        Some round the VAT to the nearest penny for each line item and others get an
        invoice total and round on that figure. Either way, it is important to know
        for each invoice (or line item) the exact number of pennies that you
        charged.

        2. VAT rates change. The last thing you want is to alter the current VAT
        rate for a certain product and find that VAT totals for past invoices are
        updated.

        Here in the UK, we try to get it right since returning incorrect tax figure
        is still punishable by death.

        Fletcher


        Comment

        • Larry  Linson

          #5
          Re: VB Calculate and update fields in Forms

          "Sven Seljom" wrote
          [color=blue]
          > Yes, that works, but I do need to use
          > a Public Function to perform the
          > operation.[/color]

          I'd say it would be _convenient_ to use a Public Function, but not a
          _necessity_.

          Larry Linson
          Microsoft Access MVP



          Comment

          Working...