Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using a function in a query

0 views
Skip to first unread message

Carol Geddes

unread,
Oct 31, 2000, 1:45:16 PM10/31/00
to
I wrote a function in a module then tried to call it in a calculated
expression in my query.
Basically all I'm trying to do is have a new field in my query that displays
a "P" or "". depending on another field having either Yes or "".It is a
Yes/No Field.
My function is:
Public PrincipalConversion()As string
If Address.Principal = "Yes" Then
PrincipalConversion = "P"
Else
PrincipalConversion = ""
End if
End Function

Then in my query I have Expr1: PrincipalConversion
When I try to run the query I get
"Can't find project or library" and it highlites my function in the module.

Thanks
Carol

--
Grant Geddes
Sutton Group S.W.
http://www.ggeddes.com
ged...@ggeddes.com


Sandra Daigle

unread,
Oct 31, 2000, 1:51:23 PM10/31/00
to
Carol,

Add a parameter to your function and then pass it in from your query.
The function doesn't know anything about the query so it can not
resolve the reference to Address.Principal. Also, if the query field
Principal is a Yes/No field, then you would use a boolean comparison
in VBA. If you don't use a boolean comparision you could compare it to
0 (No) or -1 (yes). Boolean is easier to use.

Public PrincipalConversion(fPrincipal as boolean )As string
If fPrincipal Then


PrincipalConversion = "P"
Else
PrincipalConversion = ""
End if
End Function

Then in your query:

Expr1: PrincipalConversion(Address.principal)

HTH,

Sandra Daigle


"Carol Geddes" <cge...@home.com> wrote in message
news:0rEL5.58900$76.10...@news1.rdc1.ab.home.com...

0 new messages