Custom Function - Can't Use in a Query!

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

Guest

I have a table with values in 4 columns and am trying to create a function in
VBA that I can use in building a query. Basically, what I'm looking for is
to be able to use the function in when trying to "Build" a field in Query
Design view.

When I have the Builder open, the function I created doesn't show up.

Here is the code I have in vba:
 
I have a table with values in 4 columns and am trying to create a function in
VBA that I can use in building a query. Basically, what I'm looking for is
to be able to use the function in when trying to "Build" a field in Query
Design view.

When I have the Builder open, the function I created doesn't show up.

Here is the code I have in vba:
--------------------------------------------------------
Public Function Total() As Integer

Total =
![ColA] *
![ColB] *
![ColC] *
![ColD]
End Function


Don't use the reserved word Total as the function name.

You don't need a VBA function at all - you can simply use the
expression

MyTotal: [ColA]*[ColB]*[ColC]*[ColD]

in a vacant Field cell in your Query.

If you want to use a function, you must either pass the field values
as arguments, or use DLookUp to look up the value from the table; your
Table!Column syntax simply doesn't exist within Access.

John W. Vinson[MVP]
 

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

Back
Top