Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Natural Log function be used in Access? 2

Status
Not open for further replies.

MGR

MIS
Aug 26, 1999
8
US
I would like to use the Natural Log function in Access but have been unable to determine how to implement it. Can anyone provide details on how to use it?

Thanks
 
mgr,
If you mean the LN() function as in Excel, just add the Excel library to the references and you're there. Use the Tools menu, click References, look in the list for MS Excel 8 or 9 object library, check that box, and you should have use of all Excel functions.
--Jim
 
Don't forget that it is easy to convert logs from one base to another:-

log base b of x= log base a of x \ log base a of b

Peter Meachem
peter@accuflight.com
 
Jim,

Thanks for your help. I'm presently running Access 97. I found Reference under Tools once I selected Modules and opened the Utility Functions and then I selected Excel Object Library. I still can't access the LN() function when I use the expression builder. I thought it would show up under the math function. Can you provide further assistance?

Thanks,

Mike

Peter,

Thanks for your help but I'm not sure how to implement the conversion when building an expression in Access.

Thanks,

Mike
 
This is directly copied from the Access 97 help file until the title Log.

Returns a Double specifying the natural logarithm of a number.

Syntax

Log(number)

The required number argument is a Double or any valid numeric expression greater than zero.

Remarks

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 Peter Meachem
peter@accuflight.com
 
Peter,

Thanks for the help. I was able to get it to work. I still would like to have access to the Excel function.

Mike
 
Here is one way to access this function in a module:

Dim x As Excel.Application, sngA As Single
Set x = New Excel.Application
sngA = x.ln(45)

I don't think it's available in the Expression builder, but you can use it in modules, or you could create a module-level Excel object, set it, then create a function

In the Declarations Section:
Dim XL as Excel.Application
Sometime at startup, call this function in the same module:
Function SetXl()
Set XL = new Excel.Application
End Function


Now this function is available in queries, expressions:
Function MyLN(dblInput) as Double
MyLn = XL.LN(dblInput)
Exit Function

--Jim
 
Jim,

Thanks for your help. I'll give it a try.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top