We help IT Professionals succeed at work.

MS Access 2010 power function

Mahmood Sadigh
on
Is there a power to base 10 function in Access 2010 to be used in form and reports?
Comment
Watch Question

Most Valuable Expert 2014
Commented:
It is unclear what you are asking.
^ is the exponentiation operator
2^4 equals 2 to the fourth power equals 16
101234 can be expressed as 1.01234E+6
Format the field as 'scientific' to get this result.
There are the Log, Log10 and Exp() functions
Log() is the natural logarithm
Log10() is the base 10 logarithm
Exp() raises e to the supplied power

'a power to base 10 function
Function TenX(Power as Double) as Double
TenX = 10^Power
End Function

Is this helpful?
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
And a log 10 function:
Public Function Log10( _
  ByVal dblValue As Double) _
  As Double

' Returns Log 10 of input dblValue.

  ' No error handling as this should be handled
  ' outside this function.
  '
  ' Example:
  '
  '   If dblMyValue > 0 then
  '     dblLogMyValue = Log10(dblMyValue)
  '   Else
  '     ' Do something else ...
  '   End If

  Log10 = Log(dblValue) / Log(10)

End Function

Open in new window

What is you expected input/output?

/gustav
Most Valuable Expert 2014

Commented:
From the Access 2003 help

The natural logarithm is the logarithm to the base e. The constant e is approximately 2.718282.
You can calculate base-n logarithms for any number x by dividing the natural logarithm of x by the natural logarithm of n as follows:
Logn(x) = Log(x) / Log(n)
The following example illustrates a custom Function that calculates base-10 logarithms:
Static Function Log10(X)
    Log10 = Log(X) / Log(10#)
End Function

So you could go:
Function LogBaseX(TheNumber as Double ,TheBase as double) as Double
LogBaseX = Log(TheNumber)/Log(TheBase)
End Function
And generalize that for any base
Mahmood SadighIT Manager

Author

Commented:
Thanks Gustav Brock.