Using Class Module Functions in a Query

R

Rob G

Hello All,

I consider myself on at least an intermediate level in Access and VBA
programming, but I am just beginning to explore creating class modules.

My question is, if I create a function in a class module can I use it in a
query? I tried and it didn't seem to work.

For example, I use a function in a query that returns a percentile. I tried
doing that, but I just get an 'Undefined Function' error message. I
understand why, I think.

Does it even make sense to use the function this way or are class modules
really for organizing in VBA code and nothing else?

Any enlightenment would be greatly appreciated.

Thanks.

-Rob
 
T

TPratt

Rob,

Below is an example of a module that simply adds two fields together...

------------------------------------------------------
Option Compare Database
Option Explicit

Function TestAdd(F1, F2 As Long)

TestAdd = F1 + F2

End Function
------------------------------------------------------

In the "Field" section of your query you would type something like this...

TestAdd([Field1],[Field2])


This is a simple example but it should be enough to get you started.

Tom
 

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