Connecting Tech Pros Worldwide Help | Site Map

VB Calculate and update fields in Forms

  #1  
Old November 12th, 2005, 04:00 PM
Sven Seljom
Guest
 
Posts: n/a
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



  #2  
Old November 12th, 2005, 04:00 PM
PC Datasheet
Guest
 
Posts: n/a

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
www.pcdatasheet.com


"Sven Seljom" <sven@seljom.no> wrote in message
news:fubpb.3671$mf2.47488@news4.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]


  #3  
Old November 12th, 2005, 04:00 PM
Sven Seljom
Guest
 
Posts: n/a

re: VB Calculate and update fields in Forms


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


  #4  
Old November 12th, 2005, 04:00 PM
Fletcher Arnold
Guest
 
Posts: n/a

re: VB Calculate and update fields in Forms



"PC Datasheet" <spam@nospam.com> wrote in message
news:dHbpb.2374$9M3.737@newsread2.news.atl.earthli nk.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


  #5  
Old November 12th, 2005, 04:00 PM
Larry Linson
Guest
 
Posts: n/a

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



Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating rows in a table - HELP, I'm beating my head against the wall. Laura answers 4 November 13th, 2005 05:06 AM