Max arguments for a function

D

dsm2cam

Hi All,
What is the maximum number of arguments that can be passed to a
function?

I think I'm running into a problem with this.

Access 2002, Windows 2000

Chris M
 
D

Douglas J Steele

A quick search didn't reveal any published maximum. How many arguments are
you passing, and do they have to be passed as separate arguments: could you
use an array instead?
 
D

dsm2cam

Yeah, I had looked in the help files, and didn't really see any good
solid number.

I'm passing 31 elements from a query to a function to return an
average. Source is a crosstab query with the parameters set to always
return those 31 columns.

Error comes back as being too complex. My column names may be a
problem. [07:00], [07:30],[08:00]...

It's just a rough query to put some data into excel, that will be run
once a week until Christmas. I'm coming to the conclusion that it will
probably be easier to just to the calcs by hand in Excel.

Thanks for your help though.

Chris M.
 
R

Rick Brandt

Yeah, I had looked in the help files, and didn't really see any good
solid number.

I'm passing 31 elements from a query to a function to return an
average. Source is a crosstab query with the parameters set to always
return those 31 columns.

Error comes back as being too complex. My column names may be a
problem. [07:00], [07:30],[08:00]...

It's just a rough query to put some data into excel, that will be run
once a week until Christmas. I'm coming to the conclusion that it
will probably be easier to just to the calcs by hand in Excel.

Thanks for your help though.

Chris M.

The final argument when defining a function can be set to a ParamArray which
will take any number of parameters.
 
D

David C. Holley

Never tried this with a crosstab query, but have you thought about
opening the query in code as recordset? Doing so within the function/sub
in question would eliminate the need to pass the parameters in.
 
T

Tim Ferguson

(e-mail address removed) wrote in @o13g2000cwo.googlegroups.com:
I'm passing 31 elements from a query to a function to return an
average. Source is a crosstab query with the parameters set to always
return those 31 columns.

What about passing a Fields collection: haven't tested this but something
like


public function MyAverage(F as Fields) As double

Dim fld as field, sum as double, n as integer
for each fld in F
if not isnull(fld.value)
sum = sum + fld.Value
n = n + 1
end if
next fld

MyAverage = sum/n

end function


...

set rs = db.OpenRecordset("mycrosstab")
debug.print MyAverage(rs.Fields)

...


might work?

Tim F
 
B

Brendan Reynolds

I haven't seen any documentation, but my own experience leads me to suspect
that the limit may be the length of the procedure declaration rather than
the number of arguments. You could try giving your arguments shorter names
and see if that makes any difference.
 

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