Access query
I am moving some stuff from excel to access. I am having a problem with one equation that I am trying to make a query. I have the following equation in Excel: =DEGREES(ATAN(B12/B11))
How would I write this formula in an access query.
Web Development
I am moving some stuff from excel to access. I am having a problem with one equation that I am trying to make a query. I have the following equation in Excel: =DEGREES(ATAN(B12/B11))
How would I write this formula in an access query.
by john_wills
This isn't very pretty. In the query have a calculated column, thus:
trigbit: trigthing([SSN]/[sex])
In a Visual Basic module have a constant and function, thus:
Public Const pi = 3.14159265358979
Public Function TrigThing(number As Long) As Long
TrigThing = 180 / pi * (Atn(number))
End Function
Double or Decimal may be better than long, but basically this works.
by jsteele
What is against using in your query grid the following field?
Result: Atn([b11]/[b12])*180/3,14159265358979
This assuming that the other fields in the table are b11 and b12.
NOTE It may be needed tot use . [dot] and not , [comma] in PI.
Good luck
by jsteele
by jsteele
by user9261
an easier way of writing pi is instead of 3.14..... use: pi=atn(1)*4
visual basic is a good way of solving this.
visual basic trig functions must have the angles in radians, so to convert b12 and b11 to radians if they are not in radians is to times the angle in degrees by (pi/180). rad=angle*pi/180
to convert back to degrees from radians: deg=rad*180/pi
create variables b11 and b12 as doubles:
dim b11 as double, b12 as double
atan is inverse tan. so do
atn(b12/b11)
then you must convert this to degrees
atn(b12/b11)*180/pi
so hav a variable to hold this value
dim answer as double
answer= (atn(b12/b11))*180/pi
however as you are using this in a query it would just be:
(atn(b12/b11))*180/pi
!where b12 and b11 must be field names!
that should work
by user9261
sorry, i forgot in access pi is not listed as a constant so u must use an integer 3.1415926535897932 etc. depending on the degree of accuracy you want. so it will now be:
--------------------------------
-- (atn(b12/b11))*180/3.14159 --
--------------------------------
(where b12 and b11 are field names)
by jsteele
by jsteele
This discussion is closed to new replies.
Sort by Trending