Can I reference a VB function in a query?

L

Laurel

I want to define a calculated field in an Access query
that references a function that I have written in Visual
Basic. Is this possible? I tried putting the function in
an unbound form called frmFunctions, but when I use
the "build" key in the Query Design view, functions don't
show up, just attributes.
Specifically, I need to derive the date of the first day
of the week for the value in a column. I think I need to
write a function for that.
 
G

Gary Miller

Laurel,

Yes, you certainly can. You just need to make sure and put
it in a "Public" code module that all forms, code, etc...
can reference.

At the DataBase window go to Modules, New Module and then
paste your code in there. Close the module and save it
giving it a name. basLaurelsCode???. These modules are
available throughout the whole database. Form modules are
only available to that form. Make sure you take your old one
out of the form module or you will bang heads with it.

Gary Miller
Sisters, OR
 

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