How to do the trig function Arc Cos (ACOS() in Excel) in MS-Access?

杀马特。学长 韩版系。学妹 提交于 2019-12-10 22:25:50

问题


I have an excel formula that I need to put into an MS-Access query. Unfortunately, an Arc Cosine function does not seem to be part of Access's repertoire. So in Excel, part of the formula is ACOS(Lots of stuff). So my question is how can I achieve an ACOS() Excelfunction in MS-Access?

Note: In case anyone is wondering or in case it actually matters for some odd reason, here is the full equation as it appears in Excel:

=(ACOS(SIN(RADIANS(AX2))*SIN(RADIANS(AZ2))+COS(RADIANS(AX2))*COS(RADIANS(AZ2))*COS(RADIANS(AY2)-RADIANS(BA2)))*6367)*0.621

Columns AX and AZ hold latitudes and AY and BA hold longitudes and this equation gets the distance in miles between the two points. And before anyone brings it up I am aware that Access doesn't have Radians function. I have already replaced it with an equivalent operation. I of course have changed the column references from Excel to the appropriate Access field references.


回答1:


I have found two ways to do this. The first, and the one I used, is to use an equivalent trig identity for the ACOS() function:

Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)

This results in a rather long equation for me but it works and does not appear take very long to run. The other solution I have read about (but not tested) is to create a

reference to the Microsoft Excel Object Library (Tools | References on the VBA menu bar). This exposes the Excel worksheet functions, which you can reference with:

Excel.WorksheetFunction.ACOS(TheNumberGoesHere)



来源:https://stackoverflow.com/questions/9086749/how-to-do-the-trig-function-arc-cos-acos-in-excel-in-ms-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!