How to make my User defined function work?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to create my user defined function to operate in my Access 2002, by insering in my Query. To do this, I opened visual Basic editor, and I defined my function, for example

Option Compare databas
Function z(x,y
Z= Atn(Sin(x)/ Cos(x)/Cos(y)
End Functio

Alter that, I saved it, I closed the Visual Basic Editor, and then, I tried to use it, by typing in my query var3: z(var1;var2), where var1 and var2 are variables already calculated or present in my Query. Then, ACCESS, instead of calculating the value of function showed the message: “Undefined function `z` in expressionâ€. Is there anything more than what I did to make really available to work my function? Please, help me what I need to do
Truly yours
Hirosh
 
Hiroshi,

I would try being a bit more full in the code...

Option Compare Database
Option Explicit
Public Function z(x As Double, y As Double) As Double
Z= Atn(Sin(x)/ Cos(x)/Cos(y))
End Function

Where did you put the function? It should be in a Module, and it is
important that the name of the Module is not the same as the name of the
Function z.

I also notice that you used a ; instead of a , in the example of the
calculated query field, but I assume this was only a typo.

Apart from that, I can't see anything wrong with what you have done.
 
Back
Top