UDF not passing value
I'm stumped on this one. I've created a UDF to choose the correct tax rate and pass that vaue back to the calling procedure. I ran it through a watch and the "usetaxrate" is getting the correct rate but as soon as it hits "End Function" the value clears and doesn't get passed. Any ideas would be great as I have been working on this all day with different variations with the same result. Here's the code:
Private Sub ProductID_AfterUpdate()
Dim txcharged, txrate, txprice
Set txprice = [Forms]![copy of orders]![order details subform].Form![ExtendedPrice]
txrate = gettaxrate()
txcharged = txprice * txrate
[Forms]![copy of orders]![order details subform].Form![Tax] = txcharged
End Sub
Public Function gettaxrate() As Double
Dim usetaxrate
If [Forms]![copy of orders]![order details subform]![PSTExempt] = no And [Forms]![copy of orders]![order details subform]![GSTExempt] = no Then
usetaxrate = 0
ElseIf [Forms]![copy of orders]![order details subform]![PSTExempt] = no And [Forms]![copy of orders]![order details subform]![GSTExempt] = yes Then
usetaxrate = 0.05
ElseIf [Forms]![copy of orders]![order details subform]![PSTExempt] = yes And [Forms]![copy of orders]![order details subform]![GSTExempt] = no Then
usetaxrate = 0.08
Else: usetaxrate = 0.13
End If
End Function
** As a sidenote, the logic on the IF is backwards but that's another issue for another day :-)
if PST and GST exempt, no tax charged (usetaxrate=0)
if PST exempt only, GST is charged (usetaxrate=.05)
if GST exempt only, PST is charged (usetaxrate=.08)
if neither exempt, PST/GST is charged (usetaxrate=.13)
Thank you!
|