Factorial Function

R

rascal

In access 2003 you can set a field in a table as a number and then as
Scientific. Can you set a field in a query to do a factorial calculation?
If so any ideas on how.
Thanks
 
J

Jeff Boyce

A 'factorial calculation' to me means to multiply a number by all integer
values less than or equal to that number, down to 1.

One approach would be to create a procedure/function that takes a
variable/value and calculates the factorial value. Have you looked into
Excel to see if it has such a function? If so, you could reference the
Excel object model to get at that function without having to write one
yourself.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Marshall Barton

rascal said:
In access 2003 you can set a field in a table as a number and then as
Scientific. Can you set a field in a query to do a factorial calculation?


Create your own factorial function in a standard module:

Public Function Factorial(N As Long) As Long

If N < 0 Then
MsgBox "invalid argument for Factorial"
Exit Function
ElseIf N < 2 Then
Factorial = 1
Exit Function
End If

Factorial = N * Factorial(N-1)
End Function

Then you can use it in any expression.
 
S

sean barlett

I created the module in VBA, but when I try and use the function in a report tells me to enter in a parameter value when I go to report view.

Can someone please explain why this is happening?

Thank you
 
S

sean barlett

I created the module in VBA, but when I try and use the function in a report tells me to enter in a parameter value when I go to report view.

Can someone please explain why this is happening?

Thank you
 
J

John W. Vinson

I created the module in VBA, but when I try and use the function in a report tells me to enter in a parameter value when I go to report view.

Can someone please explain why this is happening?

Please post your actual code, and the Recordsource of your report and/or the
Control Source of the report control where you're doing the calculation.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 

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