Having trouble calling custom functions in my queries

G

Guest

I have written some special functions for my database. When using the update
query wizard, I put my function name (which shows up in the functions list)
along with the arguments for my update query. When I try to run the query, I
get this message, "undefined function in expression".

I'm a novice, any help will be greatly appreciated!
 
G

Guest

Can you post the SQL and the function?

If you created the function under a form, the query won't find it, in that
case move the function to a module.

Or if you defined the function as private, the query wont recognize it, in
the case remove the private
 
G

Guest

I checked my security settings, and the box that allows access to visual
basic projects is greyed out, leaving me unable to check this box. Is there
a setting I'm missing? I've got my security settings set to 'low'.

Here's the SQL...

UPDATE RATES SET RATES.TOTALRATE =
SATtaxRET([RATES]![COMPANY],[RATES]![BASERATE],[RATES]![LOR]);

and the VB function...

Public Function SATtaxRET(company, price, days)
If days < 7 Then
BaseRate = price * days
Else
BaseRate = price
End If

If company = "Thrifty" Then
Fee1 = 1.61 * days
Fee2 = 1.7 * days
Sub1 = BaseRate + Fee1 + Fee2
TaxAP = (Sub1) * 0.1111
TaxSales5 = (Sub1 + TaxAP) * 0.05
TaxSales10 = (Sub1 + TaxAP) * 0.1
Total = Sub1 + TaxSales5 + TaxSales10 + TaxAP
SATtaxRET = Total
End If

If company = "Advantage" Then
Fee1 = 1.94 * days
Sub1 = BaseRate + Fee1
TaxAP = (Sub1) * 0.1111
TaxSales5 = (Sub1 + TaxAP) * 0.05
TaxSales10 = (Sub1 + TaxAP) * 0.1
Total = Sub1 + TaxSales5 + TaxSales10 + TaxAP
SATtaxRET = Total
End If

If company = "Alamo" Then
Fee1 = 3.25 * days
Sub1 = BaseRate + Fee1
TaxAP = (BaseRate) * 0.1111
TaxSales5 = (Sub1 + TaxAP) * 0.05
TaxSales10 = (Sub1 + TaxAP) * 0.1
Total = Sub1 + TaxSales5 + TaxSales10 + TaxAP
SATtaxRET = Total
End If

If company = "Avis" Then
Fee1 = 0.75 * days
Sub1 = BaseRate + Fee1
TaxAP = (BaseRate) * 0.1111
TaxSales5 = (Sub1 + TaxAP) * 0.05
TaxSales10 = (Sub1 + TaxAP) * 0.1
Total = Sub1 + TaxSales5 + TaxSales10 + TaxAP
SATtaxRET = Total
End If

If company = "Budget" Then
Fee1 = 2.62 * days
Sub1 = BaseRate + Fee1
TaxAP = (BaseRate) * 0.111
TaxSales5 = (Sub1 + TaxAP) * 0.05
TaxSales10 = (Sub1 + TaxAP) * 0.1
Total = Sub1 + TaxSales5 + TaxSales10 + TaxAP
SATtaxRET = Total
End If

If company = "Dollar" Then
Fee1 = 2.5 * days
Sub1 = BaseRate + Fee1
TaxAP = (Sub1) * 0.1111
TaxSales5 = (Sub1 + TaxAP) * 0.05
TaxSales10 = (Sub1 + TaxAP) * 0.1
Total = Sub1 + TaxSales5 + TaxSales10 + TaxAP
SATtaxRET = Total
End If

If company = "Enterprise" Then
Fee1 = 1.75 * days
Sub1 = BaseRate + Fee1
TaxAP = (Sub1) * 0.1111
TaxSales5 = (Sub1 + TaxAP) * 0.05
TaxSales10 = (Sub1 + TaxAP) * 0.1
Total = Sub1 + TaxSales5 + TaxSales10 + TaxAP
SATtaxRET = Total
End If

If company = "Hertz" Then
Fee1 = 1.8 * days
Sub1 = BaseRate + Fee1
TaxAP = (BaseRate) * 0.1111
TaxSales5 = (Sub1 + TaxAP) * 0.05
TaxSales10 = (Sub1 + TaxAP) * 0.1
Total = Sub1 + TaxSales5 + TaxSales10 + TaxAP
SATtaxRET = Total
End If

If company = "National" Then
Fee1 = 3.25 * days
Sub1 = BaseRate + Fee1
TaxAP = (BaseRate) * 0.1111
TaxSales5 = (Sub1 + TaxAP) * 0.05
TaxSales10 = (Sub1 + TaxAP) * 0.1
Total = Sub1 + TaxSales5 + TaxSales10 + TaxAP
SATtaxRET = Total
End If

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top